Lab Quiz 2 - Number guesser.
Due at the end of lab period.
Submit your program to your directory on neelix, in the appropriate folder.
Write a program which generates a
random number between 1 and 5 (inclusive) and asks the user to guess the number.
Give appropriate messages when the user guess correctly or incorrectly; be sure
to include the random number in the message. Continue playing until the user
enters 0.
Like so:
Program outputs: | I've chosen
a number between 1 and 5. Guess the number! (0 to quit) |
User inputs: | 3 |
Program outputs: | Sorry,
the number was 1. Please try again. I've chosen a number between 1 and 5. Guess the number! (0 to quit) |
User inputs: | 2 |
Program outputs: |
Sorry, the number was 3. Please
try again. |
User inputs: | 4 |
Program outputs: |
The number was 4! |
User inputs: | 4 |
Program outputs: |
Sorry, the number was 2. Please
try again. |
User inputs: | 0 |
Program outputs: |
Thanks for playing number guesser. |
Name your program file labquiz2.java and save it to the appropriate folder on
neelix.