Table of Contents

OddEven


Write and save a program that reads an integer and determines if it's odd or even. An input of zero counts as neither odd nor even. Here are some sample user dialogs from running this program:

         Enter an integer:  77464
         That number is EVEN.

         Enter an integer:  773
         That number is ODD.
         
         Enter an integer:  0
         That number is neither odd nor even.

Use a loop in this program to repeatedly prompt for integers to check if they are even, odd or zero.

I recommend that you write everything but the loop first. So, first, get the program to input an integer and then output whether it is EVEN, ODD or neither, and test it to make sure it does this correctly. And then, wrap a while loop around the part of the program you want to be repeated.

Version 1: while(true) - OddEven1.java

Version 2: while(true) with conditional break loop - OddEven2.java

Version 3: while(sentinel check) loop - OddEven3.java