0

For some reason that I do not know, the switch case in my CitizenMenus method returns a NoSuchElementException. I can't seem to figure out how to fix this. I would like to be enlightened as to how I could. The main method and CitizenMenus method are below.

public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        
        boolean programIsOn = true;
        boolean inMainMenu = true;

        while(programIsOn) {
            // New User
            Account myAccount = new Account();

            // Main Menu
            while(inMainMenu && programIsOn) {

                Visual.mainMenu();

                switch(sc.next().charAt(0)) {
                    case '1':
                            myAccount.register("customer");
                        break;
                    case '2':
                            if(myAccount.logIn()) {
                                CitizenMenus();
                            }
                        break;
                    case '3':
                            programIsOn = false;
                }
            }
        }
}

public static void CitizenMenus() {
        Citizen citizen = new Citizen();
        Scanner sc = new Scanner(System.in);

        boolean inCitizenMenu = true;

        while(inCitizenMenu) {
            Visual.cls();
            Visual.citizenMenu();

            switch (sc.next().charAt(0)) {
                case '1':
                        citizen.checkIn();
                    break;
                case '2':
                        citizen.reportPositive();
                    break;
                case '3':
                        citizen.changeUserInfo();
                    break;
                case '4':
                    inCitizenMenu = false;
            }
        }
    }
meksun
  • 41
  • 5

0 Answers0