title: Bank Account Program: Rejecting Deposit or Withdrawal
body: <p>I have been working on making a program to simulate bank transactions. I have to ask the user if they want to deposit, withdrawal, or transfer. Right now I am working on the deposit and withdrawal options of the account.</p>
  
  <p>When the  user selects a transaction (for example deposit) and enters a number, I made it so the program asks "Would you like to continue this transaction. Obviously, if yes the program will continue with the transaction and if no, it will not deposit the number the user entered.</p>
  
  <p>My problem is, I have no clue what I need to put in the no option. I don't know if to reject the transaction means I have to exit the loop or what but at the moment if I hit no, the transaction will still go through. Below is a visual of what happens when I enter a transaction but dont want to continue:</p>
  
  <p><img src="https://i.stack.imgur.com/FyL6O.jpg" alt="enter image description here"></p>
  
  <p>below is my entire code. the part of code I don't know what to put has ** by it
  It probably don't help my organization I am sorry for that!</p>
  
  <pre><code>import java.util.Scanner;
  
  public class BankTransactions {
  
  
  public static void main(String[] args) {
  
      Scanner scan = new Scanner(System.in);
      int num;
      double balance = 0;
      double checkingBalance= 0, savingsBalance =0;
  
      do {
  
          double amount;
  
          System.out.println("------------------------");
          System.out.println("Select a Transaction by typing number");
          System.out.println("1. Deposit");
          System.out.println("2. Withdrawal");
          System.out.println("3. Balance");
          System.out.println("4. Exit");
          System.out.println("------------------------");
          num = scan.nextInt();
  
  
          if (num == 1) { //if DEPOSIT is selected
  
              //ask to deposit from checking or savings
              System.out.println("------------------------");
              System.out.println("Would you like to deposit in checking or savings?");
                  System.out.println("1. Checking");
                  System.out.println("2. Savings");
              System.out.println("------------------------");
                  num = scan.nextInt();
  
                  if (num == 1) { //if CHECKING is selected
                      //enter amount to be deposited
                      System.out.println("------------------------");
                      System.out.println("Enter amount to deposit in checking account: ");
                      System.out.println("------------------------");
                      amount = scan.nextDouble();
  
                      //ask if they want to continue with transaction
                      System.out.println("------------------------");
                      System.out.println("Would you like to continue this transaction?");
                          System.out.println("1. Yes");
                          System.out.println("2. No");
                      System.out.println("------------------------");
                          num = scan.nextInt();
  
                      // Add the amount to the checking balance
                      checkingBalance += amount;
                      System.out.println("------------------------");
                      System.out.println("Your checking account's balance is " + checkingBalance);
                      System.out.println("------------------------");
  
                  } else if (num == 2) { //if SAVINGS is selected
                      //enter amount to be deposited
                      System.out.println("------------------------");
                      System.out.println("Enter amount to deposit in savings account: ");
                      System.out.println("------------------------");
                      amount = scan.nextDouble();
  
                      //ask if they want to continue with transaction
                      System.out.println("------------------------");
                      System.out.println("Would you like to continue this transaction?");
                          System.out.println("1. Yes");
                          System.out.println("2. No");
                      System.out.println("------------------------");
                          num = scan.nextInt();
  
                          if (num == 1) {
                              // Add the amount entered to the savings balance
                              savingsBalance += amount;
                              System.out.println("------------------------");
                              System.out.println("Your savings account's balance is " + savingsBalance);
                              System.out.println("------------------------");
                          **} else if (num == 2) {
                              //EMPTY NEEDS CODE
                          }**
                  }
  
  
          } else if (num == 2) { //if withdrawal is selected
  
              //ask to withdrawal from checking or savings
              System.out.println("------------------------");
              System.out.println("Would you like to withdrawal from checking or savings?");
                  System.out.println("1. Checking");
                  System.out.println("2. Savings");
              System.out.println("------------------------");
                  num = scan.nextInt();
  
                  if (num == 1) { //if checking is selected
                      //enter amount to be withdrawn
                      System.out.println("------------------------");
                      System.out.println("Enter amount to withdrawal: ");
                      System.out.println("------------------------");
                      amount = scan.nextDouble();
  
                      //ask if they want to continue with transaction
                      System.out.println("------------------------");
                      System.out.println("Would you like to continue this transaction?");
                          System.out.println("1. Yes");
                          System.out.println("2. No");
                      System.out.println("------------------------");
                          num = scan.nextInt();
  
                          if (num == 1) { //if you say yes to continuing
                              // Remove the amount from the balance
                              checkingBalance -= amount;
                              System.out.println("------------------------");
                              System.out.println("Your checking account's balance is " + checkingBalance);
                              System.out.println("------------------------");
                          } else if (num == 2) { //if you say no to continuing
                              //Do not remove amount from savings balance
                              //EMPTY NEEDS CODE
                          }                               
  
                  } else if (num == 2) { //if savings is selected
                      //enter amount to be withdrawn
                      System.out.println("------------------------");
                      System.out.println("Enter amount to withdrawal: ");
                      System.out.println("------------------------");
                      amount = scan.nextDouble();
  
                      //ask if they want to continue with transaction
                      System.out.println("------------------------");
                      System.out.println("Would you like to continue this transaction?");
                          System.out.println("1. Yes");
                          System.out.println("2. No");
                      System.out.println("------------------------");
                          num = scan.nextInt();
  
                          if (num == 1) { //if you say yes to continuing
                              // Remove the amount from the savings balance
                              savingsBalance -= amount;
                              System.out.println("------------------------");
                              System.out.println("Your savings account's balance is " + savingsBalance);
                              System.out.println("------------------------");
                          } else if (num == 2) { //if you say no to continuing
                              //Do not remove amount from savings balance
                              //EMPTY NEEDS CODE
                          }
                  }
  
  
          } else if (num == 3) { //if balance is selected
  
              //ask to see balance of checking or savings
              System.out.println("------------------------");
              System.out.println("Your Checking balance is " + checkingBalance);
              System.out.println("Your Savings balance is " + savingsBalance);
              System.out.println("------------------------");
                  num = scan.nextInt();
  
                  //needs to return to transaction options
          }
  
  
  
      } while (num != 4);
  
      System.out.println("------------------------");
      System.out.println("Good Bye!");
      System.out.println("------------------------");
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I am stuck and I want to figure it out. Please don't post the entire code corrected. I want to fix it myself and learn!</p>