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

Java Program *******************************************************************

ID: 3569128 • Letter: J

Question

Java Program

*******************************************************************************

import java.util.Scanner;

public class TestLoanClass {
/** Main method */
   public static void main(String[] args) {
   // Create a Scanner
      Scanner input = new Scanner(System.in);

   // Enter annual interest rate
      System.out.print(
         "Enter annual interest rate, for example, 8.25: ");
      double annualInterestRate = input.nextDouble();

   // Enter number of years
      System.out.print("Enter number of years as an integer: ");
      int numberOfYears = input.nextInt();

   // Enter loan amount
      System.out.print("Enter loan amount, for example, 120000.95: ");
      double loanAmount = input.nextDouble();

   // Create a Loan object
      Loan loan =
         new Loan(annualInterestRate, numberOfYears, loanAmount);

   // Display loan date, monthly payment, and total payment
      System.out.printf("The loan was created on %s " +
         "The monthly payment is %.2f The total payment is %.2f ",
         loan.getLoanDate().toString(), loan.getMonthlyPayment(),
         loan.getTotalPayment());
   }
}

Modify the test program to create a new object, called it carLoan, using these characteristic: interest rate is 8.50, for 5 years, and borrowed mount is $15,000. Use this new object to test all class methods. Use proper labels in your outputs. Document your code.

Explanation / Answer

import java.util.Scanner;

public class TestLoanClass {
/** Main method */
public static void main(String[] args) {
// Create a Scanner
Scanner input = new Scanner(System.in);

// Enter annual interest rate
System.out.print(
"Enter annual interest rate, for example, 8.25: ");
double annualInterestRate = input.nextDouble();

// Enter number of years
System.out.print("Enter number of years as an integer: ");
int numberOfYears = input.nextInt();

// Enter loan amount
System.out.print("Enter loan amount, for example, 120000.95: ");
double loanAmount = input.nextDouble();

// Create a Loan object
Loan loan =
new Loan(annualInterestRate, numberOfYears, loanAmount);

// Display loan date, monthly payment, and total payment
System.out.printf("The loan was created on %s " +
"The monthly payment is %.2f The total payment is %.2f ",
loan.getLoanDate().toString(), loan.getMonthlyPayment(),
loan.getTotalPayment());
         
         
         
// Create a Car Loan object
Loan carLoan =
new Loan(8.50,5, 15,000);

// Display loan date, monthly payment, and total payment
System.out.printf("The loan was created on %s " +
"The monthly payment is %.2f The total payment is %.2f ",
carLoan.getLoanDate().toString(), carLoan.getMonthlyPayment(),
carLoan.getTotalPayment());

}
}

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