Before writing any code, decide what the code is supposed to do.
When to test if there is some input
when to print out an error message
when to read the input
when to use the input
Type: Posts; User: Norm
Before writing any code, decide what the code is supposed to do.
When to test if there is some input
when to print out an error message
when to read the input
when to use the input
The hasNext methods do not read any data. They test if data is available to be read.
The next methods do read data that should be assigned to a variable so it can be used later.
This statement does...
What happens to the number that is inputted by the user in that statement? Where does it go?
You should first read it into a variable, THEN test it in case you want to use it.
Where is that message? I don't see it in the posted code.
else if(userNum.nextInt() < 0 )
What is done with the number read by nextInt() in the above statement?
It needs to be assigned to...