====== OddEven ====== ---- * Topics: Decisions, Loops 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 ===== * This version uses a simple //while(true)// loop that repeats until the user manually terminates the program. * [[https://piazza.com/class_profile/get_resource/hzkswvpxv2r2nu/i2glqyugmew1xb|Link to EvenOdd1.java]] ===== Version 2: while(true) with conditional break loop - OddEven2.java ===== * This version uses a sentinel value-controlled //while// loop that allows the user to terminate the loop by entering -9999. * This version uses a //while(true)// loop with a conditional //break// statement to exit the //while// loop. * [[https://piazza.com/class_profile/get_resource/hzkswvpxv2r2nu/i2glr2br2rc6ck|Link to EvenOdd2.java]] ===== Version 3: while(sentinel check) loop - OddEven3.java ===== * This version uses a sentinel value-controlled //while// loop that allows the user to terminate the loop by entering -9999. * The prompt for user input and user input has to be done both outside the while loop and inside the //while// loop. * [[https://piazza.com/class_profile/get_resource/hzkswvpxv2r2nu/i2glr7h83rs2|Link to EvenOdd3.java]] ----