Lab Quiz 2 - Number analyzer.
Due at the end of lab period.
Submit your program to your directory on neelix, in the RU04 folder.
Write a program which continues to
ask the user for a number between 1 and 100 (inclusive) until they enter 0 (to
quit). Validate their input. Tell the user whether each number they entered
is even or odd. After they quit, tell them how many even integers they entered,
and how many odd.
Like so:
Program outputs: |
Welcome to the number analyzer. Please enter a number between 1 and 100 (0 to quit): |
User inputs: | 67 |
Program outputs: | 67 is
odd. Please enter another (0 to quit): |
User inputs: |
4 |
Program outputs: |
4 is even. Please enter another (0 to quit): |
User inputs: | 222 |
Program outputs: |
Invalid: enter a number between 1 and 100 (0 to quit): |
User inputs: | 17 |
Program outputs: |
17 is odd. |
User inputs: | 0 |
Program outputs: |
|
Name your program file labquiz2.java and save it to the RU04 folder on neelix.
Extra credit: Attempt this
only after you have submitted a working version of the above program!
If you get this to work, you can resubmit. To resubmit, first remove the file
you originially submitted, then copy the new one there. (Neelix doesn't allow
you to overwrite a file, but you may delete one.)
For 2 points extra credit (that's an extra 20 percent), also tell whether the
number entered is a prime number. A prime number can only be divided evenly
by 1 and itself.
Program outputs: | Please enter another (0 to quit): |
User inputs: | 17 |
Program outputs: |
17 is odd. |