1 - Add employees 2 - Display all employees 3 - Display Given employee 4 - Display employees with salary higher bound 5 - Display employees with absence 6 - Display employees with earned vacation 7 - Display employees with service 8 - Remove employees 9 - Change employees 0 - Quitand reads an entry from the keyboard until "0" (for Quit) is entered. Each time a entry is read, the equivalent option label is printed, and the menu is displayed again. There should be a validation for the input; only a digit for 0 to 9 should be accepted.
Solution
public class exer3 { /* Displays a menu and reads a choice before diplaying appropriate string */ public static void main(String args[]) { /* Program statements go here. */ Integer choice; boolean endOfProgram=false; while (!endOfProgram) { System.out.println(); System.out.println("1 - Add employees"); System.out.println("2 - Display all employees"); System.out.println("3 - Display Given employee"); System.out.println("4 - Display employees with salary higher bound"); System.out.println("5 - Display employees with absence"); System.out.println("6 - Display employees with earned vacation"); System.out.println("7 - Display employees with service"); System.out.println("8 - Remove employees"); System.out.println("9 - Change employees"); System.out.println("0 - Quit"); do { System.out.print("Please enter your choice (0..9):"); choice = Keyboard.in.readInteger(); } while (choice==null || choice.intValue() < 0 || choice.intValue() >9); switch(choice.intValue()){ case 1: System.out.println("Add employees"); break; case 2: System.out.println("Display all employees"); break; case 3: System.out.println("Display Given employee"); break; case 4: System.out.println("Display employees with salary higher bound"); break; case 5: System.out.println("Display employees with absence"); break; case 6: System.out.println("Display employees with earned vacation"); break; case 7: System.out.println("Display employees with service"); break; case 8: System.out.println("Remove employees"); break; case 9: System.out.println("Change employees"); break; case 0: System.out.println("Thank you! See you later."); } endOfProgram=(choice.intValue()==0); } } }