Answers for "redeclare scanner java while loop menu option"

0

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

int choiceentry;

do {
    System.out.println("Enter "1", "2" or "3"");
    choiceentry = scanchoice.nextInt();

    switch (choiceentry)
    {
        case 1:
            // do something
            break;
        case 2: 
            // ..something else
            break;
        case 3: 
            // .. exit program
            break;
        default:
            System.out.println("Choice must be a value between 1 and 3.");
    }   
} while (choiceentry != 3);
Posted by: Guest on October-18-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language