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

A Java class with a main method. A second Java class that represents a Loan. Ple

ID: 3881453 • Letter: A

Question

A Java class with a main method. A second Java class that represents a Loan. Please help. These requirements confuse me.

Required Components: A Java class with a main method. A second Java class that represents a Loan. Use the Eclipse IDE Scenario/Information: For most home loans, there are three main values that represent the state of the: the principal (total amount loaned), interest rate (usually stored as annual rate), and total term (in years) that the homeowner has until the loan should be fully repaid. If these three values are known, then other characteristics about the loan can be calculated. For example: Monthly Rate Annual Rate/12 . Total Months Total Term * 12 Monthly Payment = Principal * Monthly Rate/ (1-(1 + Monthly Rate) Total Months)) What to do: Write a new simple Java program with Eclipse using a main method. The main method should simply declare a loan object and pass the loan object initial values for the principal, rate (APR) and term (years) It should also call a method of the Loan class to get and print the monthly payment to the console. The Loan class should include field variables for each of the basic loan values (principal, rate - APR, and term in years), two constructors (a default no-parameter constructor and a second constructor which allows all three values to be passed in to the object), getters and setters for each field variable, anda method that calculates and returns the monthly payment. Also include methods that will return the total months and monthly rate.

Explanation / Answer

import static java.lang.Math.pow;

//Class HomeLoan

public class HomeLoan

{

//Fields of the class

private double principle;

private double interest;

private int term;

//Getter Methods

public double getPrinciple() {

return principle;

}

public double getInterest() {

return interest;

}

public int getTerm() {

return term;

}

//Setter Methods

public void setAge(double newAge) {

principle = newAge;

}

public void setinterest(double newInterest) {

interest = newInterest;

}

public void setTerm(int newTerm) {

term = newTerm;

}

//Parameterless constructor

public HomeLoan()

{

}

//Parameterized constructor

public HomeLoan(double principle, double interest, int term)

{

this.principle = principle;

this.interest = interest;

this.term = term;

}

//Calculate Monthly Payment

public double MonthlyPayment()

{

this.interest /= 100.0;

double MonthlyRate = this.interest / 12;

int totalMonths = this.term * 12;

System.out.println("monthly rate : " + MonthlyRate + " totalmonths : " + totalMonths);

System.out.println();

double MonthlyPayment = (this.principle*MonthlyRate) / (1-Math.pow(1+MonthlyRate, -totalMonths));

return MonthlyPayment;

}

}

class Program

{

public static void main(String args[])

{

//Creating HomeLoan Object

HomeLoan obj = new HomeLoan(123456, 13, 5); // principle, interest, term

System.out.println("Principle : " + obj.getPrinciple() + " Interest : " + obj.getInterest() + " Term : " + obj.getTerm());

System.out.println();

//Call the method MonthlyPayment and Display the output

System.out.println("Monthly Payment : " + obj.MonthlyPayment());

}

}

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