Stefan Evans wrote:I think the most obvious thing is the use of "quotes" in places you don't need them.
Quotes around something make it that literal text value (a String)
If you want to use the variable you have declared, get rid of the quotes.
For instance
You're rightOfelia Stewart wrote:So quotes only need to be used for literal text?
Enos Winder wrote:Ok, you have some variables that need something in there besides zero right? So ask the user for it. use JOptionPane and a little parsing and you should be good to go. JOptionPane will ask the user what the program needs to know in order to run. This then makes the variable have something in it. Easy peasy.
Ofelia Stewart wrote:Like so?
That is because you are using a Scanner for your keyboard input and you don't actually need the option pane.Ofelia Stewart wrote:. . .
When I do this, it say's "Unused Import"
Campbell Ritchie wrote:
That is because you are using a Scanner for your keyboard input and you don't actually need the option pane.Ofelia Stewart wrote:. . .
When I do this, it say's "Unused Import"
What do you mean?Enos Winder wrote:ok, JOptionPane replaces system.out.println or scanner
Enos Winder wrote:Ok, If I have a piece of code that looks like this:
I can make this same code look like this:
Or, I can use JOptionPane to do this:
This is what I mean when I say replace
You don't need to parse anything in what you wrote. There are two reasons it won't work (probably more):-Enos Winder wrote:. . .
Now on the last line you will need a parse.
. . .
Campbell Ritchie wrote:
You don't need to parse anything in what you wrote. There are two reasons it won't work (probably more):-Enos Winder wrote:. . .
Now on the last line you will need a parse.
. . .1: You are trying to sort out somebody else's code and only correcting part of it. 2: You have salary uninitialised. When you get to the next line, the compiler thinks, “how much is salary? I don't know,” and won't compile any more. If you can get input via Scanner, use Scanner.
EW: option pane is a very old‑fashioned programming style. It is probably a bad idea to mix console input and GUI input anyway. You seem to be confusing OS by adding things she is unfamiliar with.
Consider Paul's rocket mass heater. |