Advertisement
CR7CR7

Bank account

Jul 25th, 2022
3,671
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.64 KB | None | 0 0
  1. public static void main(String args[])
  2.   {
  3.   // declare accounts
  4.   BankAccount a, b, c;
  5.  
  6.   // create accounts:   Name   ss_no  initial balance
  7.   a = new BankAccount("Alice", "991",  15000);
  8.   b = new BankAccount("Wei",   "995", 200000);
  9.   c = new BankAccount("Helga", "998", 100000);
  10.  
  11.   // use accounts
  12.   b.deposit(5000);
  13.   c.deposit(50000);
  14.  
  15.   if( !a.withdraw(5000) )
  16.     {
  17.     System.out.println("Insufficient funds in " + a.number);
  18.     }
  19.  
  20.   if( !a.withdraw(11000) )
  21.     {
  22.     System.out.println("Insufficient funds in " + a.number);
  23.     }
  24.  
  25.   // print statements
  26.   a.statement();
  27.   b.statement();
  28.   c.statement();
  29.   }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement