Putting too much code in the main method. That should contain one statement ideally.kennith stomps wrote:. . . . What might I be doing wrong? . . .
kennith stomps wrote:
Here is my updated code, I have used 2 classes, ...
kennith stomps wrote:
and am running into some errors in my main, the methods are not functioning properly,
as my calling and passing code is off, ...
If you spend too much time thinking about a thing, you'll never get it done. Make at least one definite move daily toward your goal. - Bruce Lee
kennith stomps wrote:
line 9 error - the method getMenuOption() is undefined for the type Calculator
kennith stomps wrote:
line 11 error - Multiple markers at this line
- choice cannot be resolved to a variable
kennith stomps wrote:
line 11 error - Multiple markers at this line
- The method getCurrentValue(double) in the type Calculator is not applicable for the
arguments ()
If you spend too much time thinking about a thing, you'll never get it done. Make at least one definite move daily toward your goal. - Bruce Lee
And the correct solution is to read the link about the main method and them move all the remaining code into a non‑static method. I wish they had said instance rather than non‑static because that error message misleads people into making things static.kennith stomps wrote:I was not wanting to use static but it was giving me errors until I did,
No, you aren't. You aren't using it all. You have it in line 31 or whatever, you then wrote too any blank lines and while you were reading those blank lines the returned value vanishes. You ought to get rid of those empty lines, but the returned value will still vanish unless you use it in the same line you are creating it on (i.e. 31). Or move the creation to a location where you can use it directly (36). The compiler won't notice that error, but it does notice that you haven't created an option variable.as for using my value returned from method immediately, I am using it immediately on my switch statement line 36
If you spend too much time thinking about a thing, you'll never get it done. Make at least one definite move daily toward your goal. - Bruce Lee
If you spend too much time thinking about a thing, you'll never get it done. Make at least one definite move daily toward your goal. - Bruce Lee
That's a pleasurekennith stomps wrote:thanks for all of your help . . .
Put goodbye one line after the end of the loop starting while (choice != 6)the program does not say goodbye upon termination . . .
I presume you have corrected that since your last post, which still has the error in.kennith stomps wrote:Aha, I was ending my while loop early as you said,
I have had a lot more practice; that's all. You would probably have had difficulty getting a debugger to stop in that loop because it is empty, but having a program sit there for several seconds without apparently doing something should alert you to the possibility of an infinite loop.took me forever to figure out something so simple, could that have been solved in debug?
Don't get me started about those stupid light bulbs. |