Question: Now create another class named SavingsAccount. This should be a subclass of BankAccount. A SavingsAccount should have an interest rate that is specified in its

Now create another class named SavingsAccount. This should be a subclass of BankAccount. A SavingsAccount should have an interest rate that is specified in its constructor. Furthermore, there should be a method, addInterest, that deposits interest into account, based on the account balance and interest rate.

Create another subclass of BankAccount named CheckingAccount. A CheckingAccount should keep track of the number of transactions made (deposits and withdrawals). Name this field transactionCount. Also, the set fee for transactions is three dollars, so create a static final field, TRANSACTION_FEE, that is set to 3.0. Finally, create a method, deductFees, that deducts fees from the account balance based on the number of transactions. This method should reset the transactionCount to zero.

Now make a class BankAccountTest with a main method to test the above classes. Create a SavingsAccount with zero balance, a 1% interest rate, and a name of your choice. Also create a CheckingAccount with a $500 initial balance and a name of your choice. Deposit $1000 into the SavingsAccount. Withdraw $100 from the CheckingAccount. Now transfer $200 from the SavingsAccount to the CheckingAccount. Print out both accounts. Now add interest to theSavingsAccount and deduct fees from the CheckingAccount. Print out both accounts and make sure the balances are as expected.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!