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

I am getting error in this area, it seems I don\'t have Days class. any suggesti

ID: 3770054 • Letter: I

Question

I am getting error in this area, it seems I don't have Days class. any suggestion to fix it ?

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

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

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;
}
}

Explanation / Answer

The following function converts time to milli seconds and computes the difference. After that it converts into no of days

public class Days {

   public double daysBetween(Date date1, Date date2) {
       long msec1 = date1.getTime(); //milli seconds
       long msec2 = date2.getTime(); //time in milli seconds
      
       long diff = msec1 - msec2;
       //1 day = 24 hours = 86,400 seconds = 86,400,000 millis seconds
       double days = (double) diff / 86400000.0;
       return days;
   }
}