Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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.

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

PostgreSQL Up And Running A Practical Guide To The Advanced Open Source Database

Authors: Regina Obe, Leo Hsu

3rd Edition

1491963417, 978-1491963418

More Books

Students also viewed these Databases questions