title: Switch Statement stops compiling after a certain selection
body: <p>I have written an ATM program, but seem to be having issues within my mainMenuOptions() method. My switch statements all seem to work fine and loop back around for user ID input, and Selection of what you'd like to do with the ATM. When the user gets to case 4 however everything prints as it is supposed to but the menu never comes back up so you can move on. If you enter any number after the output of case 4 you just get the message BUILD SUCCESSFUL, and you must restart the program.</p>
  
  <p>I need case four to function the same way as cases 1, 2, 3, and 5. I need it to be selected and produce the output below and continue the program.</p>
  
  <p><strong>Expected OutPut</strong></p>
  
  <p>Main Menu</p>
  
  <ol>
  <li><p>Check Balance</p></li>
  <li><p>Withdraw</p></li>
  <li><p>Deposit</p></li>
  <li><p>Account Information</p></li>
  <li><p>Exit (choose a different account)</p></li>
  </ol>
  
  <p>Please make a selection: 4</p>
  
  <p>Account was created on: Tue Oct 23 19:27:22 EDT 2018</p>
  
  <p>Account interest rate is: 0.65</p>
  
  <p>Account Balance is: 44.0</p>
  
  <p>Main Menu</p>
  
  <ol>
  <li><p>Check Balance</p></li>
  <li><p>Withdraw</p></li>
  <li><p>Deposit</p></li>
  <li><p>Account Information</p></li>
  <li><p>Exit (choose a different account)</p></li>
  </ol>
  
  <p><strong>Actual OutPut</strong></p>
  
  <p>Main Menu</p>
  
  <ol>
  <li><p>Check Balance</p></li>
  <li><p>Withdraw</p></li>
  <li><p>Deposit</p></li>
  <li><p>Account Information</p></li>
  <li><p>Exit (choose a different account)</p></li>
  </ol>
  
  <p>Please make a selection: 4</p>
  
  <p>Account was created on: Tue Oct 23 19:27:22 EDT 2018</p>
  
  <p>Account interest rate is: 0.65</p>
  
  <p>Account Balance is: 44.0</p>
  
  <p>BUILD SUCCESSFUL</p>
  
  <p>My Code is below.....</p>
  
  <pre><code>import java.util.Date;
  import java.util.Scanner;
  
  
  
  public class test {
  
      private static Account[] accounts = new Account[10];
  
      public static void main(String[] args) {
  
  
  
          accounts();
          mainMenuOptions();
      }
      //main menu option method
      public static void mainMenuOptions() {
          Scanner input = new Scanner(System.in);
  
          Date d = new Date();
  
          int enterchoice = -1;
          int id=-1;
          while (enterchoice != 4) {
              mainMenu();
              //enter id
              System.out.println("Enter an id: ");
              id = input.nextInt();
              System.out.println("Enter choice: ");
              enterchoice = input.nextInt();
  
              int index = -1;
              for (int i = 0; i &lt; accounts.length; i++) {
                  if (accounts[i].getid() == id) {
                      index = i;
                      break;
                  }
              }
              switch (enterchoice) {
              case 1:
                  System.out.println("The balance is " + accounts[index].getbalance());
                  break;
              case 2:
                  {
                      System.out.println("Enter an amount to withdraw ");
                      double amount = input.nextDouble();
                      //withdraw method
                      accounts[index].withdraw(amount);
                      break;
                  }
              case 3:
                  {
                      System.out.println("Enter an amount to deposit ");
                      double amount = input.nextDouble();
                      //deposit method
                      accounts[index].deposit(amount);
                      break;
                  }
              case 4:
                  {
                      System.out.println("Account was created on: " + d.toString());
                      System.out.println("Account interest rate is: " + accounts[index].getMonthlyInterestRate());
                      System.out.println("Account balance is: $" + accounts[index].getbalance());
                      double amount = input.nextDouble();
                      //display date account created, account interest rate, and balance
                      accounts[index].deposit(amount);
                      break;
                  }
              case 5:
                  {
                      System.out.println("Exit (choose a different account)");
                      double amount = input.nextDouble();
                      //loop back through program to make new account selection
                      break;
                  }
              default:
                  break;
              }
          }
      }
  
      public static void accounts() {
          //create accounts
          //initialize 100 dollars
          for (int i = 0; i &lt; accounts.length; i++) {
              accounts[i] = new Account(i, 100);
          }
      }
  
      //main menu method
      public static void mainMenu() {
  
          System.out.println("Main menu" + "\nEnter a choice" + "\n1:Check Balance" + "\n2:Withdraw" + "\n3:Deposit" + "\n4:Account Information" + "\n5:Exit (choose a different account)");
  
      }
  
      //main menu method
      public static void mainMenus() {
          System.out.println("Main menu" + "\nEnter a choice" + "\n1:Check Balance" + "\n2:Withdraw" + "\n3:Deposit" + "\n4:Account Information" + "\n5:Exit (choose a different account)");
  
      }
  
      private String dateCreated;
  }
  class Account{
      private int id = 0;
      private double balance = 0;
      private static double annualInterestRate = 7.8;
      private final double withdraw;
      private final double deposit;
      private final double amount;
      private java.util.Date dateCreated;
      private Object getMonthlyInterestRate;
  
      Account(){
          this.amount = 0;
          this.withdraw = 0;
          this.deposit = 0;
          this.dateCreated.toString();
          this.getMonthlyInterestRate.toString(); 
  
      }
  
  
      Account(int id, double balance){
          this.amount = 0;
          this.withdraw = 0;
          this.deposit = 0;
          this.id = id;
          this.balance = balance;
      }
  
      public int getid(){
          return this.id;
  
      }
      public void setid(int newid){
          id = newid;
      }
      public double getbalance(){
          return this.balance;
      }
      public double getMonthlyInterestRate() {
          return (annualInterestRate / 12);
      }
  
      public double getMonthlyInterest() {
          return balance * getMonthlyInterestRate();
      }
  
      public void withdraw(double amount){
          balance = balance - amount;
      }
  
      public void deposit(double amount){
          balance = balance + amount;
      }
  
  
  }
  </code></pre>