Mr_Linnenburger

BankAccountRunnerClass

Jan 10th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.06 KB | None | 0 0
  1. //Copy and paste this class into your existing BankAccountRunner class code.
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class BankAccountRunner
  6. {
  7.     public static void main()
  8.     {
  9.         Scanner kb = new Scanner(System.in);
  10.        
  11.         System.out.println("----------------------------------------------------------");
  12.         System.out.println(" Welcome to the Accountinator 8750XS Bank Account System");
  13.         System.out.println("----------------------------------------------------------");
  14.        
  15.        
  16.         System.out.print("Please enter your name: ");
  17.         String name = kb.nextLine();
  18.         System.out.print("Please enter a starting balance: ");
  19.         double amount = kb.nextDouble();
  20.         System.out.print("Pleaes enter an integer key value: ");
  21.         int key = kb.nextInt();
  22.         kb.nextLine(); //clean out System.in;
  23.        
  24.         BankAccount ba = new BankAccount(name, amount, key);
  25.         System.out.println(ba);
  26.        
  27.        
  28.         boolean running = true;
  29.         String input;
  30.        
  31.         while(running)
  32.         {
  33.             System.out.print("Choose an option:\n(d)eposit\n(w)ithdrawl\n(u)nlock\n(l)ock\n(s)etkey\n(p)rint account info\n(q)uit\nYour choice: ");
  34.             input = kb.nextLine();
  35.            
  36.             if(input.equals("d"))
  37.             {
  38.                 System.out.print("How much to deposit: ");
  39.                 amount = kb.nextDouble();
  40.                 kb.nextLine(); //clean out System.in;
  41.                 ba.deposit(amount);
  42.             }
  43.             else if(input.equals("w"))
  44.             {
  45.                 System.out.print("How much to withdraw: ");
  46.                 amount = kb.nextDouble();
  47.                 kb.nextLine(); //clean out System.in;
  48.                 ba.withdraw(amount);
  49.             }
  50.             else if (input.equals("p"))
  51.             {
  52.                 System.out.println(ba);
  53.             }
  54.             else if (input.equals("q"))
  55.             {
  56.                 running = false;
  57.             }
  58.             else if(input.equals("s")){
  59.                 System.out.print("enter a new integer key value: ");
  60.                 key = kb.nextInt();
  61.                 kb.nextLine();
  62.                 ba.setKey(key);
  63.             }
  64.             else if(input.equals("u")){
  65.                 System.out.println("please enter the key to unlock the account: ");
  66.                 key = kb.nextInt();
  67.                 kb.nextLine();
  68.                 ba.unlock(key);
  69.             }
  70.             else if(input.equals("l")){
  71.                 System.out.println("please enter the key to lock the account: ");
  72.                 key = kb.nextInt();
  73.                 kb.nextLine();
  74.                 ba.lock(key);
  75.             }
  76.             else
  77.             {
  78.                 System.out.println("BAD INPUT");
  79.             }
  80.         }
  81.         System.out.println("----------------------------------------------------------");
  82.         System.out.println("       Thanks for using Accountinator 8750XL!");
  83.         System.out.println("----------------------------------------------------------");
  84.     }
  85. }
Add Comment
Please, Sign In to add comment