Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Copy and paste this class into your existing BankAccountRunner class code.
- import java.util.Scanner;
- public class BankAccountRunner
- {
- public static void main()
- {
- Scanner kb = new Scanner(System.in);
- System.out.println("----------------------------------------------------------");
- System.out.println(" Welcome to the Accountinator 8750XS Bank Account System");
- System.out.println("----------------------------------------------------------");
- System.out.print("Please enter your name: ");
- String name = kb.nextLine();
- System.out.print("Please enter a starting balance: ");
- double amount = kb.nextDouble();
- System.out.print("Pleaes enter an integer key value: ");
- int key = kb.nextInt();
- kb.nextLine(); //clean out System.in;
- BankAccount ba = new BankAccount(name, amount, key);
- System.out.println(ba);
- boolean running = true;
- String input;
- while(running)
- {
- 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: ");
- input = kb.nextLine();
- if(input.equals("d"))
- {
- System.out.print("How much to deposit: ");
- amount = kb.nextDouble();
- kb.nextLine(); //clean out System.in;
- ba.deposit(amount);
- }
- else if(input.equals("w"))
- {
- System.out.print("How much to withdraw: ");
- amount = kb.nextDouble();
- kb.nextLine(); //clean out System.in;
- ba.withdraw(amount);
- }
- else if (input.equals("p"))
- {
- System.out.println(ba);
- }
- else if (input.equals("q"))
- {
- running = false;
- }
- else if(input.equals("s")){
- System.out.print("enter a new integer key value: ");
- key = kb.nextInt();
- kb.nextLine();
- ba.setKey(key);
- }
- else if(input.equals("u")){
- System.out.println("please enter the key to unlock the account: ");
- key = kb.nextInt();
- kb.nextLine();
- ba.unlock(key);
- }
- else if(input.equals("l")){
- System.out.println("please enter the key to lock the account: ");
- key = kb.nextInt();
- kb.nextLine();
- ba.lock(key);
- }
- else
- {
- System.out.println("BAD INPUT");
- }
- }
- System.out.println("----------------------------------------------------------");
- System.out.println(" Thanks for using Accountinator 8750XL!");
- System.out.println("----------------------------------------------------------");
- }
- }
Add Comment
Please, Sign In to add comment