A good answer might be:

A sentinel-controlled loop. (In this case any good integer works as the sentinel, which causes the loop to exit).

Sample Output

Here is some sample 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 NumberFormatException be thrown?

Click Here after you have answered the question