title: Generating a bill
body: <p>I am having a problem. In the last switch statement when i press 4 that is to return to main menu. All the values that is entered for 1,2,3 gets reset. What should i do so that these values doesn't get reset. 
  package Assignment;</p>
  
  <pre><code>import java.util.Scanner;
  
  public class Assign3 {
      public static void main(String[] args) {
          Scanner s = new Scanner(System.in);
          int menuSel;
          Boolean done = false;
          for (int i = 0; i &lt;= 78; i++) {
              System.out.print("=");
          }
          System.out.println("\n\t\t FEDERATION UNIVERSITY PHONE BILL COMPARISON SYSTEM");
          System.out.println("");
          System.out.println("Developed by Abhitesh Jindal, Student ID 30334858 for ITECH1000 Semester 1 2017");
          System.out.println("");
          for (int i = 0; i &lt;= 78; i++) {
              System.out.print("=");
          }
          while (!done) {
              System.out.println("\nMAIN MENU");
              System.out.println("Please select an option from the menu: "
                      + "\n\t 1. Enter Usage Details \n\t " + "2. Display Cost Under Plan A \n\t "
                      + "3. Display Cost Under Plan B \n\t " + "4. Clear Usage Details \n\t "
                      + "5. Exit System");
              System.out.println("Enter selection:");
              menuSel = s.nextInt();
              switch (menuSel) {
              case 1:
                  System.out.print(" Enter Usage Details ");
                  submenu();
                  break;
              case 2:
                  System.out.print("Display Cost Under Plan A");
                  break;
              case 3:
                  System.out.println("Display Cost Under Plan B");
                  break;
              case 4:
                  System.out.println("Clear Usage Details");
                  break;
              case 5:
                  System.out.println("Exit System");
                  done = true;
                  break;
              default:
                  System.out.println("Value must be between 1 and 5. Please try again:");
                  break;
              }
          }
          s.close();
      }
  
      static void submenu() {
          Scanner a = new Scanner(System.in);
          Boolean done1 = false;
          int numCalls = 0;
          int SMS = 0;
          int callLength = 0;
          int totalCallSeconds = 0;
          while (!done1) {
              System.out.println("\nENTER USAGE DETAILS MENU: " + "\n1. Phone Call" + "\n2. SMS"
                      + "\n3. Data Usage" + "\n4. Return to main menu");
              System.out.println("Enter Selection:");
              int subMenu = a.nextInt();
              switch (subMenu) {
              case 1:
                  System.out.println("Enter Length of Call in Seconds:  ");
                  ++numCalls;
                  System.out.println("Total Call" + numCalls);
                  callLength = a.nextInt();
                  totalCallSeconds = totalCallSeconds + callLength;
                  System.out.println("Total Seconds" + totalCallSeconds);
                  if (callLength &lt; 1) {
                      System.out.println("Value must be positive.Please Enter value again");
                      callLength = a.nextInt();
                      totalCallSeconds = totalCallSeconds + callLength;
                      System.out.println("Total Seconds" + totalCallSeconds);
                  }
                  break;
              case 2:
                  ++SMS;
                  System.out.print("Total number of SMS= " + SMS);
                  break;
              case 3:
                  System.out.println("Enter amount of Data used:");
                  int DataUsed = a.nextInt();
                  if (DataUsed &lt; 1) {
                      System.out.println("Value must be positive");
                      System.out.println("Enter Value again");
                      DataUsed = a.nextInt();
                  }
                  break;
              case 4:
                  System.out.println("Return to mainu menu");
                  return;
              default:
                  System.out.println("Invalid Selection");
                  break;
              }
          }
          a.close();
      }
  }                       
  </code></pre>