Question: The java programing question goes like this: Write two classes to describe BankAccount objects. A bank account is described by the account owner's name, an

The java programing question goes like this:

Write two classes to describe BankAccount objects.

A bank account is described by the account owner's name, an account ID (stored as text), and the balance in the account.

A savings account is a type of bank account that is described by this same information and also by an interest rate.

In each class, include (or use inherited versions of):

instance data variables

two constructors

one constructor takes a starting balance; the second constructor creates an account with no money

you decide what other parameters should be included in each

getters and setters

include appropriate value checks when applicable

a toString method

you decide the output

a deposit method

include appropriate value checks

a withdrawal method

include appropriate value check

I already did some part:

public class SavingsAccount extends BankAccount {

private double interestRate;

private double minBalance;

// private static final double DEFAULD_BALANCE = 0.00;

public SavingsAccount(String name, String id, double balance, double interestRate, double minBalance) {

super(name, id, balance);

this.interestRate = interestRate;

this.minBalance = minBalance;

}

/*

* public SavingsAccount(String name, String id,double interestRate){

*

* this(name, id, DEFAULD_BALANCE, interestRate); }

*/

public double getInterestRate() {

return interestRate;

}

@Override

public void setBalance(double newBalance) {

if (newBalance >= minBalance) {

balance = newBalance;

}else {

System.out.println("Invalid Value.");

}

}

public void setInterstRate(double newInterestRate) {

interestRate = newInterestRate;

}

@Override

public String toString() {

String s = super.toString() + "\tInterest Rate: " + interestRate;

return s;

}

@Override

public boolean withdrawal(double withdrawleValue) {

if ((balance - withdrawleValue) >= minBalance) {

return super.withdrawal(withdrawleValue);

} else {

System.out.println("Banlance cannot be less than minimun balance. ");

return false;

}

}

}

My question is :

Include a minimum balance as part of what describes a savings account. Update the class as necessary, making sure that the account is not allowed to go below this minimum balance. (use the saving account program above)

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!