Description
Create an Inheritance hierarchy that a bank may use to represent customer’s bank accounts (Checking and Savings).
All the bank customers can deposit (Credit) money into their account and/or withdraw (debit) money from their account.
Create necessary classes and Java application to use and test these classes.
Savings Accounts – earn interest on the money in the account.
Checking accounts – charges a fixed fee for each transaction the customer makes.
Create base class Account, with derived classes SavingsAccount and CheckingAccount that inherit from Account
Account:contains – initialBalance
Constructors, getter/setters
validation for initialBalance,
credit() – make input is correct and positive and credit the account
debit() – make sure there is enough money, otherwise it should left unchanged
Account:SavingsAccount
Inherit from Account
additional property called interestRate (percentage assigned to account)
SavingsAccount Constructor should receive initialBalance, value for interestRate
method calculateInterest() that returns the amount of interest
CheckingAccount
Inherit from Account
additional instance variable for fee charged per transaction
Constructor should receive the initialBalance and fee amount
Should redefine debit () and credit () to take under consideration the fee charged
Now create and application that creates objects of each class to test each method.
Add interest to the savingsAccount object by first invoking its caculateInterest () method, then pass the returned interest amount to the object’s credit () method.
Develop a polymorphic banking application using the Account hierarchy. Create an array of Account references to SavingsAccount and CheckingAccount objects.
For each account in the array, allow the user to specify an amount of money to withdraw from the account using method debit() and an amount to deposit into the account using the method deposit().
As you process each Account, determine its type.
If an account is a SavingsAccount, calculate the amount of interest owed to the Account using method calculateInterest(), then add the interest to the account balance using method credit().
After processing an Account, print the updated balance obtained by using the getBalance() from the base class.
Interactively ask the user for information for each account and then print the result for each account.
Create Custom Exception NegativeBalanceException for the cases when user try to withdraw amount beyond available balance.