Fill This Form To Receive Instant Help

Help in Homework
trustpilot ratings
google ratings


Homework answers / question archive / Java homework help Define four chasset: Account, Savings, Checking, and Bank

Java homework help Define four chasset: Account, Savings, Checking, and Bank

Computer Science

Java homework help

Define four chasset: Account, Savings, Checking, and Bank. Account is the superdass, Savings.
and Checking are subclasses, ard Bank class will be the driver class with main(},
Note: You should have a maird) in each class and to test the methods in each class independently
to make sure the class works as intended (ust like what you have done in Assignment 2). Than
you should make the main(} in the class Bank the driver of the program,
1. For the Account class, create:
1, Three protected variables far account number, account balance, and account type, as.
well ax the corresponding getters and setters.
2. Aconstructor that requires an account number as argument and sets the account
balance tod.
3, Amethod to override the toString() method to return 2 String 3s follows:
Account #9 < account auenber>
Account Balance » <account balance>

(where <account number> is the abject’s account number and method. For example, the interest on $6000 at 2% for three years is (1 + 0.02)* * 6000
<account balance> is the object's account balance). - 6000 = $367.25.
4. Two methods deposit{} and withdraw/), each takes one double argument of the
amount to deposit or withdraw. The methads should update the account balance. Do 4. Create a class called Bank. This is the class that contains the main method as the driver
not allow the account balance to become negative. If the updated balance will of the program, i.e., the program starts in this main().
become negative, a message should be displayed to show that the user does not have
enough fund for withdrawal and the withdrawal does not happen. a. You may use one or more ArrayList(s} to store objects of the Savings and Checking
5. A computeinterest{) method that takes a double argument of interest period and class If you use two Arraylists, then one should be for Checking accounts and the
returns a double. This method returns no interest (because the interest rate is ather for Saving accounts. (Hint: you should make this a private instance variable,
unknown yet}. similar to that in the Bank class in Assignment 4}
b. Use 2% (.02} as the Savings account rate. (Hint: consider make this a constant)
2. The Checking dass will be a subclass of Account. For the Checking class, create: c. Static variables to keep track of the number of Savings and Checking objects
1. Aconstant for interest rate at 0.5% (remember the naming convention) instantiated.
2. Amethod to override the toString{) method to return a String: d. Write a method that requires an integer n to initialize n account objects with account
Checking Account # = < account number> numbers starting from 101 and increment by 1, and set the initial balance of each
Checking Balance = <account balance> account to be 50 times the account number. Make the account Checking if the
(where <account number> is the object's account number and account number is odd, otherwise Savings.
<account balance> is the object's current account balance).
Do not print the interest earned as part of toString/}. ¢  Thatis, account 101 is Checking with an initial balance S0SO, account 102 is
3. Aconstructor that takes an account number and account balance as arguments and Savings with an initial balance 5100, account 103 is Checking with an initial
calls the superclass constructor passing this account number. The account type balance 5150, account 104 is Savings with an initial balance 5200, and so on.
should also be specified, e-g., ‘c’ for checking account. (Hint: you need to use appropriate constructors to create the accounts)
4. Amethod to override the computeinterest() method of the superciass. This method
takes one argument for the interest period and returns the simple interest earned. e. The program should allow users to perform the following operations until the user
The interest earned is the interest rate 0.5% times the balance times the interest wants to quit:
period. The interest period is passed as an argument to the computeinterest()
method. For example, the interest on $3000 at 0.5% for 2.5 years is 3000 ° .005 * 2.5= check individual account by the account number. If the account number does
$37.5. not exist, a proper message should be displayed. If the account number
exists, the program should allow users to continually choose to do the
3. The Savings class will also be a subclass of Account. For the Savings class, create: following until s/he wants to go back to the main menu:
a. A private variable to hold the interest rate, and the get and set methods for the i. perform deposits - the account information should be displayed after
interest rate. Do nat allow the interest rate to be set ta a negative number. When each transaction.
that happens, make the interest rate zero. ii, perform withdrawals - the account information should be displayed
b. Amethod to override the toString{) method to return a String: after each transaction.
Savings Account # = < account number> iii. display information of the account
Savings Balance = <account balance> ¢ display the information in all the bank accounts using the overridden
Savings Interest Rate = <interest rate> toString() methads and print the interest amount computed for each
(where <account number> is the object's account number, <account account. Use 2 years for the time period. (Hint: Again, consider making this
balance> is the object's account balance, and <interest rate> is the value a constant}
object's interest rate}. © display all the Savings accounts using the overridden taString(} methods,
Do not print the interest earned as part of toString(}. including the interest amount computed for each account. Use the constant
c. Aconstructor with two arguments - the account number and the interest rate. This interest period of 2 years.
constructor calls the superclass constructor passing the account number. The account © display all the Checking accounts using the overridden toString() methods,
type should also be specified, e.g., ‘s’ for savings account. - including the interest amount computed for each account. Use the constant
d. Amethod to override the computeinterest() method of the superclass. This method interest period of 2 years.
takes one argument for the interest period and returns the compound interest
earned. The interest is calculated as (1 + interest rate)" times the balance minus
the balance. The interest period is passed as an argument to the computeinterest()

Option 1

Low Cost Option
Download this past answer in few clicks

17.99 USD

PURCHASE SOLUTION

Already member?


Option 2

Custom new solution created by our subject matter experts

GET A QUOTE