go to previous page   go to home page   go to next page

Answer:

The current line of input from the user is defective. The statement

scan.nextLine();

reads and discards the current line.


Sample Output

Here is some output from the program:

Enter an integer: rats
You entered bad data.
Please try again.

Enter an integer:
-12
The square of -12 is 144

QUESTION 9:

If the user entered 34.56 would a InputMismatchException be thrown?


go to previous page   go to home page   go to next page