The BankAccount class models an account of a customer. A BankAccount has the followinginstance variables: A unique account id sequentially assigned when the Bank Account is created. A balance which represents the amount of money in the account A date created which is the date on which the account is created.The following methods are defined in the BankAccount class: Withdraw – subtract money from the balance Deposit – add money to the balance Inquiry on:o Balanceo Account ido Date createdThe SavingsAccount class models a bank account which is meant for long term savingsand earns interest. It inherits all the fields and methods of the BankAccount class. TheSavingsAccount class has an additional instance variable, interest rate. The interest rate is adecimal representing the rate at which the account earns interest. For example, an interestrate of .01 means that the account will earn 1% interest on its balance.The following additional methods are defined in the SavingsAccount class: Calculate interest – returns the result of calculating the interest amount based on thecurrent balance and interest rate. It does not update the balance Inquiry on interest rate. Modifying the interest rate.The CheckingAccount class models a bank account which is used to write checks andmake frequent ATM deposits and withdrawals. This type of account does not earn interest.The CheckingAccount class inherits all the fields and methods of the BankAccount class. Ithas an additional instance variable, monthly fee. The monthly fee is an amount of moneycharged by the bank for its services.The following additional methods are defined in the CheckingAccount class: Deduct monthly fee – updates the balance by deducting the monthly fee Inquiry on monthly fee. Modifying the monthly fee Write the BankAccount, CheckingAccount and SavingsAccount classes usinginheritance. Include a client program with a main method, xxxx_program4, which will dothe following: Prompt the user for information needed to create a savings account and a checkingaccount Create a SavingsAccount object and a CheckingAccount object using the information Prompt the user for an amount to deposit into the savings account Deposit the amount into the savings account Prompt the user for an amount to withdraw from a checking account Withdraw the amount from the checking account Deduct the monthly fees from the checking account Calculate the interest and deposit the interest amount into the savings account. Print the savings account and checking account as shown in the sample output.Sample output:Enter the amount of money to create a savings account1000Enter the interest rate of the savings account.01Enter the amount of money to create a checking account2000Enter the monthly fee of the checking account50Amount to deposit into the savings account?1000Amount to withdraw from the checking account?100Calculating and adding interest of savings accountDeducting monthly fee from checking accountSavings accountAccount ID: 1 Created on Wed Mar 29 12:21:05 EDT 2017 Balance: 2020.0 Interest Rate:0.01Checking accountAccount ID: 2 Created on Wed Mar 29 12:21:12 EDT 2017 Balance: 1850.0 Monthly Fee:50.0

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter11: Advanced Inheritance Concepts
Section: Chapter Questions
Problem 13PE
icon
Related questions
Question

The BankAccount class models an account of a customer. A BankAccount has the following
instance variables:
 A unique account id sequentially assigned when the Bank Account is created.
 A balance which represents the amount of money in the account
 A date created which is the date on which the account is created.
The following methods are defined in the BankAccount class:
 Withdraw – subtract money from the balance
 Deposit – add money to the balance
 Inquiry on:
o Balance
o Account id
o Date created
The SavingsAccount class models a bank account which is meant for long term savings
and earns interest. It inherits all the fields and methods of the BankAccount class. The
SavingsAccount class has an additional instance variable, interest rate. The interest rate is a
decimal representing the rate at which the account earns interest. For example, an interest
rate of .01 means that the account will earn 1% interest on its balance.
The following additional methods are defined in the SavingsAccount class:
 Calculate interest – returns the result of calculating the interest amount based on the
current balance and interest rate. It does not update the balance
 Inquiry on interest rate.
 Modifying the interest rate.
The CheckingAccount class models a bank account which is used to write checks and
make frequent ATM deposits and withdrawals. This type of account does not earn interest.
The CheckingAccount class inherits all the fields and methods of the BankAccount class. It
has an additional instance variable, monthly fee. The monthly fee is an amount of money
charged by the bank for its services.
The following additional methods are defined in the CheckingAccount class:
 Deduct monthly fee – updates the balance by deducting the monthly fee
 Inquiry on monthly fee.
 Modifying the monthly fee

Write the BankAccount, CheckingAccount and SavingsAccount classes using
inheritance. Include a client program with a main method, xxxx_program4, which will do
the following:
 Prompt the user for information needed to create a savings account and a checking
account
 Create a SavingsAccount object and a CheckingAccount object using the information
 Prompt the user for an amount to deposit into the savings account
 Deposit the amount into the savings account
 Prompt the user for an amount to withdraw from a checking account
 Withdraw the amount from the checking account
 Deduct the monthly fees from the checking account
 Calculate the interest and deposit the interest amount into the savings account.
 Print the savings account and checking account as shown in the sample output.
Sample output:
Enter the amount of money to create a savings account
1000
Enter the interest rate of the savings account
.01
Enter the amount of money to create a checking account
2000
Enter the monthly fee of the checking account
50
Amount to deposit into the savings account?
1000
Amount to withdraw from the checking account?
100
Calculating and adding interest of savings account
Deducting monthly fee from checking account
Savings account
Account ID: 1 Created on Wed Mar 29 12:21:05 EDT 2017 Balance: 2020.0 Interest Rate:
0.01
Checking account
Account ID: 2 Created on Wed Mar 29 12:21:12 EDT 2017 Balance: 1850.0 Monthly Fee:
50.0

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 1 images

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT