title: How to exit from a submenu back to a main menu?
body: <p><strong>I have the following simple main menu without any methods called in it, and I'm lost at how to make the sub-menu exit back to the main menu when the exit option is chosen in each?</strong> 
  I'm quite the beginner and this project is quite important as if I fail I won't be able to do my exam despite having paid for it already :(</p>
  
  <p><strong>The menu code (so far) is the following:</strong></p>
  
  <p>*//The menu will consist of 6 listings being: Books, Members, Employees, Loans, Statistics, Exit.</p>
  
  <p>//These listings from 1 to 4 will open a submenu consisting of: Insert, Search, Delete, Edit, List All, Exit.</p>
  
  <p>//Listing 5 will consist of: Top 5 Books, Top 5 Members, Employee of the Month, List Overdues, Exit.</p>
  
  <pre><code>    import java.util.*;
      import java.io.*;
      public class Menu
        {
      public static void main(String args[]) throws IOException
        {
      Scanner sc = new Scanner(System.in);
      int option; 
  
      do 
      { 
      System.out.println("Main Menu:"); 
      System.out.println("1. Books"); 
      System.out.println("2. Members"); 
      System.out.println("3. Employees"); 
      System.out.println("4. Loans");
      System.out.println("5. Statistics");
      System.out.println("6. Exit");
      System.out.println("Enter your option [1,2,3,4,5,6]:");
      option = sc.nextInt();
  
      switch (option) {
          case 1: System.out.println("Books Sub-Menu:");
                  System.out.println("1. Insert"); 
                  System.out.println("2. Search"); 
                  System.out.println("3. Delete"); 
                  System.out.println("4. Edit");
                  System.out.println("5. List All");
                  System.out.println("6. Exit"); 
                  System.out.println("Enter your option [1,2,3,4,5,6]:");
                  option = sc.nextInt();
  
                  switch (option){
                      case 1:
                      case 2: 
                      case 3:
                      case 4:
                      case 5:
                      case 6:
                      option = sc.nextInt();
                      break;
                  }
          break;
  
          case 2: System.out.println("Members Sub-Menu:");
                  System.out.println("1. Insert"); 
                  System.out.println("2. Search"); 
                  System.out.println("3. Delete"); 
                  System.out.println("4. Edit");
                  System.out.println("5. List All");
                  System.out.println("6. Exit"); 
                  System.out.println("Enter your option [1,2,3,4,5,6]:");
                  option = sc.nextInt();
  
                   switch (option){
                      case 1: 
                      case 2: 
                      case 3:
                      case 4:
                      case 5:
                      case 6:
                      option = sc.nextInt();
                      break;
                  }
          break;
  
          case 3: System.out.println("Employees Sub-Menu:");
                  System.out.println("1. Insert"); 
                  System.out.println("2. Search"); 
                  System.out.println("3. Delete"); 
                  System.out.println("4. Edit");
                  System.out.println("5. List All");
                  System.out.println("6. Exit"); 
                  System.out.println("Enter your option [1,2,3,4,5,6]:");
                  option = sc.nextInt();
  
                   switch (option){
                      case 1: 
                      case 2: 
                      case 3:
                      case 4:
                      case 5:
                      case 6:
                      option = sc.nextInt();
                      break;
                  }
          break;
  
          case 4: System.out.println("Loans Sub-Menu:");
                  System.out.println("1. Insert"); 
                  System.out.println("2. Search"); 
                  System.out.println("3. Delete"); 
                  System.out.println("4. Edit");
                  System.out.println("5. List All");
                  System.out.println("6. Exit"); 
                  System.out.println("Enter your option [1,2,3,4,5,6]:");
                  option = sc.nextInt();
  
                   switch (option){
                      case 1: 
                      case 2: 
                      case 3:
                      case 4:
                      case 5:
                      case 6:
                      option = sc.nextInt();
                      break;
                  }
          break;
  
          case 5: System.out.println("Statistics Sub-Menu:");
                  System.out.println("1. Top 5 Books"); 
                  System.out.println("2. Top 5 Members"); 
                  System.out.println("3. Emplyee of the Month"); 
                  System.out.println("4. List Overdue");
                  System.out.println("5. Exit"); 
                  System.out.println("Enter your option [1,2,3,4,5]:");
                  option = sc.nextInt();
  
                   switch (option){
                      case 1: 
                      case 2: 
                      case 3:
                      case 4:
                      case 5:
                      case 6:
                      option = sc.nextInt();
                      break;
                  }
          break;
  
          case 6: System.out.println("You selected to Exit");
                  System.exit(0);
                  break;
      }
  
     }  while (option!=6);
  
      }
      }*
  </code></pre>