The current code will not all you to enter invalid data. Is that what you want it to do?
Do you know how to code a try{}catch block to catch the error?
Type: Posts; User: Norm
The current code will not all you to enter invalid data. Is that what you want it to do?
Do you know how to code a try{}catch block to catch the error?
The test does NOT make sense. userinput is an int variable and can ONLY hold int values.
Have you removed that invalid and senseless statement, compiled the code, executed it and tried to enter...
Comment out the invalid code, compile and execute the program and enter some invalid data to see what happens.
int userinput = keyboard.nextInt();
boolean hasInt = false;
...
Have you tried executing the code and entering non-integer data? What happened?
Hint: read the API doc for the nextInt() method.
If its in the same program, continue here.
I don't see any brackets with the for statements which is one place they should be.
One problem I see with the code is the missing {} following each for statement. Always use {}s to surround the statements that are in the for loop.
Also the code is not properly formatted. Nested...
What is the format that you need? Give an example.
One problem I see with the code is the missing {} following each for statement. Always use {}s to surround the statements that are in the for...
Please copy the full text of the error message and paste it here. It has important info about the error.
Please edit your post and wrap your code with code tags:
<YOUR CODE HERE>
to get...