Answers for "how to create a menu in java using switch and while loop"

0

How to make a Java Main Menu Loop after using a case

//set choiceentry to -1, this will make it to enter while loop
     int choiceentry = -1

    while(choiceentry < 1 || choiceentry > 3){

            System.out.println("Enter "1", "2", "3" or "4"");
            if(scanchoice.hasNextInt())
            choiceentry = scanchoice.nextInt();

    }

     switch(choiceentry){
        case 1:
           //do logic
           break;
        case 2:
           //do logic
           break;
        case 3:
           //do logic
           break;
   }
Posted by: Guest on October-18-2020

Code answers related to "how to create a menu in java using switch and while loop"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language