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

Question The following class Loan has incomplete codes. Complete the missing lin

ID: 3846251 • Letter: Q

Question

Question The following class Loan has incomplete codes. Complete the missing lines of codes for the given parameterized constructor, isToMonitor method, and toString() method. Hint: If the loan amount exceeds $500000.00 then it needs to be monitored. The method ‘isToMonitor’ has to return true or false accordingly.

import java.time.*;

public class Loan

{

private double loanAmount;

private LocalDate startDate;

private static double LIMIT = 500000.0;

/** * @param givenLoanAmount the loan amount *

@param year the year of startDate *

@param month the month of startDate *

@param day the day of startDate */

public Loan ( double givenLoanAmount, int year, int month, int day)

{ //Missing lines of code have to be completed }

public boolean isToMonitor()

{ //Missing lines of code have to be completed }

@Override public String toString()

{ //Missing lines of code have to be completed }

}//end class definition

Explanation / Answer

Below is your program: -

Loan.java


import java.time.*;

public class Loan {
   private double loanAmount;
   private LocalDate startDate;
   private static double LIMIT = 500000.0;

   /**
   * * @param givenLoanAmount the loan amount *
   *
   * @param year
   * the year of startDate *
   * @param month
   * the month of startDate *
   * @param day
   * the day of startDate
   */
   public Loan(double givenLoanAmount, int year, int month, int day) {
       this.loanAmount = givenLoanAmount;
       this.startDate = LocalDate.of(year, month, day);
   }

   public boolean isToMonitor() {
       if(this.loanAmount > LIMIT) {
           return true;
       } else {
           return false;
       }
   }

   @Override
   public String toString() { // Missing lines of code have to be completed
       if(isToMonitor()) {
           return "Loan Amount : "+this.loanAmount+" started on "+this.startDate.toString()+" is monitored";
       } else {
           return "Loan Amount : "+this.loanAmount+" started on "+this.startDate.toString()+" is not monitored";
       }
   }
   // end class definition
}

LoadDriver.java (Simple loan driver class to test the Loan class)


public class LoanDriver {
   public static void main(String[] args) {
       Loan aLoan = new Loan(50000, 2016, 03, 26);
       Loan bLoan = new Loan(5000000, 2017, 06, 26);
       System.out.println(aLoan);
       System.out.println(bLoan);
   }
}

Sample Run:-

Loan Amount : 50000.0 started on 2016-03-26 is not monitored
Loan Amount : 5000000.0 started on 2017-06-26 is monitored

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote