0

Im am trying to figure out a way to check the type of the input a user enters in a Scanner object . This scanner object is also in a method. I need the method to run again after telling the user to use a number. I have gone as far as ending the program after the use inputs an invalid type now I need to go one step further. This section of code is in the method, and yes its in a do while loop because there could be an infinite amount of employees.

do {
        System.out.println("Select an option from the choices below \n"
                        + "1 - Add an employee \n"
                        + "2 - Change an employees salary \n"
                        + "3 - Delete an employee \n"
                        + "4 - List an employee \n"
                        + "5 - List all employees \n"
                        + "Enter any other number to exit.");



        //Check to see if input equals and integer
                try{
                    inputOption = scanner.nextInt();
                }
                catch(InputMismatchException e){
                    System.out.println("Please enter a number.");
                    scanner.

                }
JavaFox
  • 61
  • 14

0 Answers0