on line 17 I call getMenuOption, with x inside the parameter. What exactly does x repsresent? I am trying to pass my menu selection input to the getMenuOption that was called in the main method.
however, when I go to make my switch statement, I use x within my parameters, should I be using variable x or variable menuselection?
kennith stomps wrote:
You cannot do this, the x variable is not yet initialized and cannot be passed to getMenuOption before.
Obviously a variable name "x" isn't descriptive (unless you are calculating coordinates). You are calling a method named getMenuSelection, what does it return?
Also, you should only create a Scanner for System.in *once* and then reuse it.
also my num1 and num2 operand inputs give me the error of not being initialized.
any suggestions on better passing within parameters
If getMenuOption() is no longer taking a parameter, why are you attempting to pass one in?
Carey Brown wrote:You are repeating the same problem. You are passing in a variable "op" and then not using it. Only pass in the values you actually need to perform some operation.
You seem to be under the misconception that in order to get something out that you have to pass it in first. This is not true.
...now All of my return answers are not being resolved to a variable in my switch statements, any idea how to fix this part?
the input for choice menu selection is also invalid
You didn't follow my example correctly. You still need to call getMenuOption() inside the do() loop.
Carey Brown wrote:That's because you've defined "choice" inside the "do" block. Outside of the block (which ends with a '}') the variable goes out of scope and is no longer visible. The while() expression is outside of the block, hence, cannot see "choice". (You're not the only one to get confused by this.) The solution is to define "choice" before you enter the "do" block.
Usually the "case 1:" is on a line by itself and the body of the case indented one more level. And don't forget to add breaks.
would you simply change the double to a float?