Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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: One constructor that receives the initial balance withdraw subtract money from the balance deposit add money to the balance Getters for: o Balance o Account id o Date created toString prints the object in the following format: Account ID: 1 Balance: 2020.0 Date Created Wed Jan 20 12:21:05 EDT 2017 The SavingsAccount class models a bank account which is meant for long term savings and earns interest. A SavingsAccount is-a BankAccount. 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: One constructor that receives the initial balance and the interest rate calculateInterest returns the result of calculating the interest amount based on the current balance and interest rate. It does not update the balance. Getter and setter for interest rate. toString adds to super.toString() to print the object in the following format: Account ID: 1 Balance: 2020.0 Date Created Wed Jan 20 12:21:05 EDT 2017 Interest Rate: 0.01 The CheckingAccount class models a bank account which is used to write checks and make frequent ATM deposits and withdrawals. A CheckingAcccount is a BankAccount. This type of account does not earn interest. The CheckingAccount class inherits all the fields and methods of the BankAccount class (again, these are inherited, not rewritten!). 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: One constructor that receives the initial balance and the monthly fee deductFee updates the balance by deducting the monthly fee Getter and setter for monthly fee. toString adds to super.toString() to print the object in the following format: Account ID: 2 Balance: 1850.0 Date Created Wed Jan 20 12:21:12 EDT 2017 Monthly Fee: 50.0 Program requirements Write the BankAccount, CheckingAccount and SavingsAccount classes as described above, using inheritance. Include a client class driver program) with a main method, xxxx, which will do the following: Prompt the user for information needed to create one savings account and one 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 Calculate the interest and deposit the interest amount into the savings account. Deduct the monthly fees from the checking account Print the savings account and checking account as shown in the sample output, using the objects toString() methods. Sample output: Enter the amount of money to create a savings account 800 Enter the interest rate of the savings account .02 Enter the amount of money to create a checking account 900 Enter the monthly fee of the checking account 50 Amount to deposit into the savings account? 200

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

Database And Expert Systems Applications 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 Proceedings Part 1 Lncs 13426

Authors: Christine Strauss ,Alfredo Cuzzocrea ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

3031124227, 978-3031124228

More Books

Students also viewed these Databases questions