this a part of my code that if I have multiple if statement each of them return an integer value and the method itself was declared to return an integer but when I compile this method I got an error "missing return statment". but when I change the code to be if.../else if statements, no errors appeared but I don't know why.
You got "missing return statment" because there are cases when end of method could be reached without hitting a return statement.
Take a look.
Execute this using pencil and paper or in your head. What will the method return if you pass g = 3 into it?