Problem Please provide comments and all the steps to solve
Problem ( Please provide comments and all the steps to solve this problem )
Implement in Java a superclass BankAccount. Make two subclasses, SavingAccount and CheckingAccount, that inherit from BankAccount. A bankAccount has a balance (instance var). A savingAccount has an interestRate (instance var) indicating the interest rate in percent. A checkingAccount has an operationCount (instance var) and two constants: FREE_OPERATIONS = 5 and OPERATION_FEE = 2.5.
Write the class declarations, the constructors and the following methods:
BankAccount:
deposit(); withdraw(double amount); getBalance(); and transfer(BankAccount other, double amount)
SavingAccount:
addInterest to increase the current balance using the interestRate percent.
CheckingAccount:
deductionFees() to deduct from the current balance the OPERATION_FEE amount when the operationCount > FREE_OPERATIONS, and then set operationCount = 0.
Please note that for the checkingAccount objects, every time you call the deposit or the withdraw methods you need to increase the operationCount var.
Supply a test program that tests these classes and methods.
Solution
code:
class BankAccount
 {
 float balance;
 public BacnkAccount()
 {
 balance=0;
 }
 public BankAccount(float b)
 {
 balance =b;
 }
 public deposit(float mon)
 {
 balance+=mon;
 }
 public withdraw(float mon)
 {
 balance -=mon;
 }
 public float getbalance()
 {
 return balance;
 }
 }
 class SavingAccount extends BankAccount{
 float interestRate;
 public SavingAccount()
 {
 interestRate = 0;
 }
 public SavingAccount(float ir)
 {
 interestRate = ir;
 }
 public addInterest()
 {
 balance+= (balance*interestRate);//increment the balance
 }
   
 }
 class CheckingAccount extends BankAccount
 {
 int OperationCount;
 float FREE_OPERATIONS = 5;
 float OPERATION_FEE = 2.5.
 CheckingAccount()
 {
 OperationCount=0;
 }
 public deductionFees()
 {
 if(operationCount > FREE_OPERATIONS)
 {
 balance -= OPERATION_FEE;
 operationCount = 0;
 }
 }
 public deposit(float mon)
 {
 balance+=mon;
 operationCount++;//overwriting the method
 }
 public withdraw(float mon)
 {
 balance -=mon;
 operationCount++;//overwriting the method
 }
 }


