0

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 :)

2
Contributors
2
Replies
9
Views
4 Years
Discussion Span
Last Post by stultuske
0

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 by OsamaJutt_1: copy two times

0

create methods:

printMainMenu();
printSubMenu1();
...

and on

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

...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.