Write an application that asks a user to type an even number to continue or to type 999 to stop. When the user types an even number, display the message “Good job!” and then ask for another input. When the user types an odd number, display an error message and then ask for another input. When the user types 999, end the program.
static int number; static Scanner scanner = new Scanner(new DataInputStream(System.in));
public static void main(String[] args) { System.out.println("Hi!"); while (true) { System.out.println("Please type an even number to continue or '999' to stop"); number = scanner.nextInt(); if (number == 999) { System.out.println("Bye!"); System.exit(0); } if (number % 2 != 0) { System.out.println("Wrong input! Try again."); } else { System.out.println("Good job!"); } } }
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments