fork download
  1. // ************************************************************
  2. // ManageAccounts.java
  3. //
  4. // Use Account class to create and manage Sally and Joe's
  5. // bank accounts
  6. // ************************************************************
  7. public class ManageAccounts {
  8.  
  9. public static void main(String[] args) {
  10. Account acct1, acct2;
  11. //create account1 for Sally with $1000
  12. acct1 = new Account(1000, "Sally", 1111);
  13.  
  14. //create account2 for Joe with $500
  15. acct2= new Account(500,"Joe",2222);
  16.  
  17. //deposit $100 to Joe's account
  18. acct2.deposit(100);
  19.  
  20. //print Joe's new balance (use getBalance())
  21. System.out.println("Joe's balance after $100 deposit is "+acct2.getBalance());
  22.  
  23. //withdraw $50 from Sally's account
  24. acct1.withdraw(50);
  25.  
  26. //print Sally's new balance (use getBalance())
  27. System.out.println("Sally's balance after $50 withdrawal is "+acct1.getBalance());
  28.  
  29. //charge fees to both accounts and prints balances
  30. System.out.println("Sally's balance after $10 fee is "+acct1.chargeFee());
  31. System.out.println("Joe's balance after $10 fee is "+acct2.chargeFee());
  32.  
  33. //change the name on Joe's account to Joseph
  34. acct2.changeName("Joseph");
  35.  
  36. //print summary for both accounts
  37. System.out.println("\nAccount 1 summary");
  38. System.out.println(acct1);
  39. System.out.println("\nAccount 2 summary");
  40. System.out.println(acct2);
  41. }
  42. }
  43.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty