Hello Guys, I am facing problem while i am create menu system using swtich statement. I have 3 level of menu but don't know how to go back to main switch Statement. For Example currently I am in 2nd level of switch but how to go in main(outer) switch. Please its Urgent. Thanxxx in advance :)

System.out.println("******Welcome To Main Menu*******");

System.out.println("******Welcome To Main Menu*******");   
        System.out.println("\n");
        System.out.println("\t------------------------------------");
        System.out.println("\t|Commands: 1 - Manage Item         |");
        System.out.println("\t|          2 - Make New Sale       |");
        System.out.println("\t|          3 - Make Payemt         |");
        System.out.println("\t|          4 - Print Report        |");
        System.out.println("\t|          5 - Exit                |");
        System.out.println("\t------------------------------------");
        System.out.println("");
        int a=in.nextInt();

        switch(a)
        {
            case 1:
        System.out.println("\t------------------------------------");
        System.out.println("\t|Commands: 1 - Add New Item         |");
        System.out.println("\t|          2 - Find Item            |");
        System.out.println("\t|          3 - Modify Item          |");
        System.out.println("\t|          4 - Remove Item          |");
        System.out.println("\t|          5 - Go Back              |");
        System.out.println("\t------------------------------------");
        System.out.println("");
                int b=in.nextInt();
                switch(b)
                {
                    case 1:
                        im.AddNewItem();
                        break;
                    case 5:
                      //from here I want to go back to main switch  
                }
                break;
            case 5:

        }

Edited 3 Years Ago by OsamaJutt_1: copy two times

create methods:

printMainMenu();
printSubMenu1();
...

and on

case 5:
  --counter;
    if ( counter == 0 ) printMainMenu();

...

This article has been dead for over six months. Start a new discussion instead.