Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have to construct Inheritance hierarchy that a bank may use to represent customer's bank accounts (Checking and Savings). All the bank customers can deposit

I have to construct 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.

Make any 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.

Construct base class Account, with derived classesSavingsAccountandCheckingAccountthat inherit from

Account

Account:

contains -initialBalance

Constructors, getter/setters

validation forinitialBalance,

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 calledinterestRate(percentage assigned to account)

SavingsAccountConstructor should receiveinitialBalance, value forinterestRate

methodcalculateInterest() that returns the amount of interest

CheckingAccount

Inherit from Account

additional instance variable for fee charged per transaction

Constructor should receive theinitialBalanceand fee amount

Should redefine debit () and credit () to take under consideration the fee charged

Now construct an application that creates objects of each class to test each method.

Add interest to thesavingsAccountobject by first invoking itscalculateInterest() method, then pass the returned interest amount to the object's credit () method.

Develop a polymorphic banking application using the Account hierarchy. Make an array of Account references toSavingsAccountandCheckingAccountobjects.

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 credit().

As you process each Account, determine its type.

If an account is aSavingsAccount, calculate the amount of interest owed to the Account using methodcalculateInterest(), then add the interest to the account balance using method credit().

After processing an Account, print the updated balance obtained by using thegetBalance() from the base class.

Interactively ask the user for information for each account and then print the result for each account.

Lastly, i have to also create Custom ExceptionNegativeBalanceException for the cases when user try to withdraw amount beyond availablebalance.

There will be three classes, account, saving account and checking account. account will be the base class and other will be the subclass that extends account.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions