Question: Please do this in java Design a class named Account that contains: * A private int data field named id (whose default value is 0).

Please do this in java

Design a class named Account that contains:

* A private int data field named id (whose default value is 0).

* A private double data field named balance (whose default value is 1000).

* A private double data field named annualInterestRate (whose default value is 4.50).

* A no-arg constructor that creates a new Account object with default values. * A second constructor that creates an Account with a specified id and non-negative

initial balance (and the default interest rate).

* A third constructor that creates an Account with a specified id, non-negative initial balance, and non-negative interest rate.

* public accessor and mutator methods for all three instance variables. * A public method named getMonthlyInterestRate() that returns the monthly

interest rate (annualInterestRate/12).

* A public method named withdraw() that takes a double argument. If the account balance is smaller than that amount, print a statement saying that there are insufficient funds and leave the balance unchanged. Otherwise, deduct the argument value from the current account balance.

* A public deposit() method that adds the value of its (positive) double argument to the current account balance.

* A public toString() method that prints the values of each instance variable in an appropriate format.

Next, create a subclass of Account named CheckingAccount. A CheckingAccount has an overdraft limit (a double instance variable whose value is set by an additional constructor and a mutator method); if you attempt to withdraw more money than the account currently has, the withdrawal still succeeds as long as the total amount is less than or equal to the current balance plus the overdraft limit (the account balance just becomes negative after this). Override toString() to include the overdraft limit.

Write a test program that creates one Account and one CheckingAccount and invokes their toString() methods.

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!