Question: Java-Classes and objects, inheritance write 4 classes for program_bcs and all classes in one file b_acc The following methods are defined in the b_acc class:

Java-Classes and objects, inheritance

write 4 classes for program_bcs and all classes in one file

b_acc

The following methods are defined in the b_acc class:

One constructor that receives the initial balance

withdraw subtract money from the balance

deposit add money to the balance

Getters for:

Balance

Account id

Date created

toString prints the object in the following format:

Account ID: 1 Balance: 2020.0 Date Created Sat Feb 20 12:21:05 EDT 2016

s_acc

For 1% its 0.01%

The following additional methods are defined in the s_acc 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 Sat Feb 20 11:59:58 EDT 2016 Interest Rate: 0.01

c_acc

The following additional methods are defined in the c_acc 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 Sat Feb 20 12:30:45 EDT 2016 Monthly Fee: 50.0

Program requirements

Write the b_acc, c_acc and s_acc classes as described above, using inheritance. Include a client class (i.e., driver program) with a main method,

Prompt the user for information needed to create one savings account and one checking account

Create a s_acc object and a c_acc object using the information

Prompt the user for an amount to deposit into the s_acc

Deposit the amount into the s_acc

Prompt the user for an amount to withdraw from a c_acc

Withdraw the amount from the c_acc

Calculate the interest and deposit the interest amount into the s_acc

Deduct the monthly fees from the c_acc

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 s_acc

800

Enter the interest rate of the s_acc

.02

Enter the amount of money to create a c_acc

900

Enter the monthly fee of the c_acc

50

Amount to deposit into the s_acc?

200

Amount to withdraw from the c_acc?

100

Calculating and adding interest of s_acc.

Deducting monthly fee from c_acc.

S_acc:

Account ID: 1 Balance: 1020.0 Date Created Tue Oct 10 09:46:11 EST 2017

Interest Rate: 0.02 C_acc:

Account ID: 2 Balance: 750.0 Date Created Tue Oct 10 09:46:11 EST 2017

Monthly Fee: 50.0

Remember to remove the public modifier on the classes that do not have the main method (e.g., b_acc, s_acc, and c_acc).

Program class should retain its public modifier.

For all classes include the following:

o Use of inheritance: reuse, do not recode

o Instance variables

o Constructors

o Accessor and mutator methods

o Suitable toString() methods which make use of method overriding

Write a class Program_bcs which has a main method that creates the objects and calls the required methods as described in the program requirements section.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!