Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need to modify this Extended Savings account which has a balance, interest rat

ID: 3769807 • Letter: I

Question

I need to modify this Extended Savings account which has a balance, interest rate and lockout time span An extended savings account is like a savings account except no withdrawals are allowed during the time span provided. This means if an extended savings account is created with a span of 60 days, no withdrawals can occur during that time frame. If an attempted withdrawal occurs, the system will not allow it. :

---------------------------------------------------------------------------------

package bankapp;

public class ExtendedSavingAccount extends BankAccount
{
      private double interest = 0.0;

   ExtendedSavingAccount(String name, double balance, int dateCreated)
   {

       super(name, balance);

       this.accountType = " extended saving";
   }
   float interestRate, displayBalance;

   int bal;

    double interestRate()
   {
    if (bal <30)
    {
      balance = balance*0.05f;
    }else if (bal <60)
        {
            balance = balance * 0.06f;
        }else if (bal < 90)
            {
                balance = balance * 0.08f;
            }else if (bal < 180)
                {
                    balance = balance * 0.1f;
                }
    return balance;
   }
    double displayBalance()
   {
       return balance;
   }
    @Override
   public String toString()
        {
          return " Name: " + customerName + " Balance:"+ balance + " Date:"+ dateCreated;
        }
}

Explanation / Answer

public class ExtendedSavingAccount extends BankAccount
{
private double interest = 0.0;
private int lockOutPeriod;
ExtendedSavingAccount(String name, double balance, int dateCreated,int lockOutPeriod)
{

super(name, balance);
this.bal = balance;
this.accountType = " extended saving";
this.lockOutPeriod = lockOutPeriod;
}
float interestRate, displayBalance;

int bal;

void withdrawal(int amount){
if(Days.daysBetween(Calendar.getInstance().getTime(), dateCreated).getDays() > lockOutPeriod){
super.withdrwa(amount); //call base class withdraw method
}
}

double interestRate()
{
if (bal <30)
{
balance = balance*0.05f;
}else if (bal <60)
{
balance = balance * 0.06f;
}else if (bal < 90)
{
balance = balance * 0.08f;
}else if (bal < 180)
{
balance = balance * 0.1f;
}
return balance;
}
double displayBalance()
{
return balance;
}
@Override
public String toString()
{
return " Name: " + customerName + " Balance:"+ balance + " Date:"+ dateCreated;
}
}