Reorganize the bank account classes as follows. In the BankAccount class, introduce an abstract method endOfMonth with no implementation. Rename the addInterest and deductFees methods into endOfMonth in the subclasses. Which classes are now abstract and which are concrete? Write a static method void test(BankAccount account) that makes five transactions and then calls endOfMonth. Test it with instances of all concrete account classes.

Complete the following files:

AccountTester2.java

CheckingAccount.java

SavingsAccount.java

Use the following files:

AccountTester.java

/**
   This program tests the BankAccount class and its subclasses.
*/
public class AccountTester
{
   public static void main(String[] args)
   {
      SavingsAccount momsSavings = new SavingsAccount(5);
      CheckingAccount harrysChecking = new CheckingAccount(0);
      
      test(momsSavings);
      System.out.println(momsSavings.getBalance());      
      System.out.println("Expected: 6300");
      
      test(harrysChecking);
      System.out.println(harrysChecking.getBalance());      
      System.out.println("Expected: 5996");
   }

   public static void test(BankAccount account)
   {
      for (int i = 1; i <= 5; i++)
      {
         if (i % 2 == 1)
            account.deposit(i * 1000);
         else
            account.withdraw(i * 500);
      }

      account.endOfMonth();
   }
}

BankAccount.java

/**
   A bank account has a balance that can be changed by 
   deposits and withdrawals.
*/
public abstract class BankAccount
{  
   private double balance; 

   /**
      Constructs a bank account with a zero balance.
   */
   public BankAccount()
   {  
      balance = 0;
   }

   /**
      Constructs a bank account with a given balance.
      @param initialBalance the initial balance
   */
   public BankAccount(double initialBalance)
   {  
      balance = initialBalance;
   }
 
   /**
      Deposits money into the bank account.
      @param amount the amount to deposit
   */
   public void deposit(double amount) 
   {  
      balance = balance + amount;
   }

   /**
      Withdraws money from the bank account.
      @param amount the amount to withdraw
   */
   public void withdraw(double amount) 
   {  
      balance = balance - amount;
   }

   /**
      Gets the current balance of the bank account.
      @return the current balance
   */
   public double getBalance()
   {  
      return balance; 
   }
   

   /**
      Abstract method that performs the end of month adjustment.
   */
   public abstract void endOfMonth();
}