Advertisement
semsem_elazazy

Untitled

May 20th, 2022
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.95 KB | None | 0 0
  1. package taylor;
  2. import java.util.ArrayList;
  3. import java.util.Scanner;
  4.  
  5. public class TestBank{
  6.  
  7.   public static void main(String args[]){
  8.  
  9.  
  10.     ArrayList<Customer> accounts = new ArrayList<Customer>();
  11.  
  12.     Customer customer1 = new Customer(1, "Savings", "US Dollars", 800);
  13.     Customer customer2 = new Customer(2, "Checking", "Euro", 1900);
  14.     Customer customer3 = new Customer(3, "Checking", "US Dollars", 8000);
  15.  
  16.     accounts.add(customer1);
  17.     accounts.add(customer2);
  18.     accounts.add(customer3);
  19.  
  20.  
  21.     int customerID=4;
  22.     String choice;
  23.     int deposit;
  24.     int withdraw;
  25.     Scanner in = new Scanner(System.in);
  26.     Customer operation = new Customer();
  27.     boolean flag = true;
  28.  
  29.     String accountType;
  30.     String currencyType;
  31.     int balance;
  32.  
  33.     while(flag){
  34.       System.out.println("Select a choice:");
  35.       System.out.println("1. Existing customer");
  36.       System.out.println("2. New customer");  
  37.       System.out.println("3. Quit");
  38.  
  39.  
  40.       String input = in.next();
  41.  
  42.         //existing user
  43.         if(input.equals("1")){
  44.  
  45.           System.out.println("Enter CustomerID: ");
  46.           customerID = in.nextInt();
  47.  
  48.  
  49.           System.out.println("Would you like to: ");
  50.           System.out.println("1. Deposit ");
  51.           System.out.println("2. Withdraw ");
  52.           System.out.println("3. Display account info ");
  53.           System.out.println("4. Check balance ");
  54.  
  55.           choice = in.next();
  56.  
  57.           if(choice.equals("1")){
  58.             System.out.println("How much would you like to deposit?");
  59.             deposit = in.nextInt();
  60.             operation.deposit(deposit);
  61.           }
  62.  
  63.           else if (choice.equals("2")){
  64.            System.out.println("How much would you like to withdraw?");
  65.             withdraw = in.nextInt();
  66.             operation.withdraw(withdraw);
  67.  
  68.           }
  69.  
  70.           else if (choice.equals("3")){
  71.             operation.display(accounts.get(customerID));
  72.           }
  73.  
  74.           else if (choice.equals("4"))
  75.             operation.balance(accounts.get(customerID));
  76.  
  77.           else
  78.             System.out.println("Invalid");
  79.         }
  80.  
  81.  
  82.  
  83.         //new user
  84.          else if(input.equals("2")){
  85.           //add new user to arraylist
  86.  
  87.            int newID = customerID + 1;
  88.  
  89.            System.out.println("Enter account type: ");
  90.            accountType = in.next();
  91.            System.out.println("Enter currency type: ");
  92.            currencyType = in.next();
  93.            System.out.println("Enter initial balance: ");
  94.            balance = in.nextInt();
  95.  
  96.            System.out.println("Your customer ID will be: " + newID);
  97.  
  98.  
  99.            accounts.add(new Customer(newID, accountType, currencyType, balance));
  100.  
  101.  
  102.         }
  103.  
  104.         else if(input.equals("3")){
  105.  
  106.           System.out.println("Thanks for using this bank!");
  107.           flag = false;
  108.         }
  109.  
  110.  
  111.         else{
  112.  
  113.           System.out.println("Invalid");
  114.  
  115.         }
  116.       }
  117.  
  118.     }
  119. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement