Your Mortgage Payment Calculator application was very well r
Your Mortgage Payment Calculator application was very well received. The VP of IT has commended you on your work. When you inquire about the promised big raise he says “About that. You see the company is redoing my office. There was a miscommunication with the vendor and the desk, bookcases, coffee table, and end tables were supposed to be made from Gabon Ebony. Instead they were made from Padauk. Because of this, the price has gone up, so there is not as much wiggle room in the budget anymore. But I will see what I can do. You keep up the good work!”
You sulk back to your desk thinking that it might be time to update the old resume. Your phone is ringing off the hook. It is the Senior VP of IT calling to say that the mortgage analysts are again on the verge of revolt. (It\'s like déjà vu all over again!) Since the system is still down, they cannot provide their customers with loan comparison information. They demand that IT creates a GUI program that shows a table of loan comparison information.
The Senior VP of IT has asked you to get something together yesterday. When you ask if there is a bonus or raise in it for you he says “You’re the miracle worker. This is part of your job! DO IT!!!”
A programmer’s work is never done.
Specifications
You will need to ask for a Loan Amount, and Number of Years. The user will input these via text fields.
There will be a Show Table button that when pressed will create a table with monthly and total payments for each interest rate starting from 5% to 8%, in increments of 0.125%. This will be displayed in a Grid Pane.
The GUI should look something like this:
The interest rate should always have 3 places after the decimal point. Monthly Payment and Total Payment should be formatted as Currency.
Hint: Look at the NumberFormat class or the format method in the String class.
Use a Border Pane for holding everything. Use the NORTH area for user interaction. Use the CENTER area for the table.
The code for the Loan Class is included at the end of this document.
Error Checking
Inputs
Make sure all fields are numbers.
The Loan Amount can be between $1,000 and $100,000.
The Number of Years can be between 1 and 20.
All fields need to be correct when the Show Table button is pressed.
The user will be able to change any of the fields and press the Show Table button.
Use a Try-Catch blocks where you deem appropriate.
Commenting
Use the generated flower box in BlueJ to provide a description of the Class and your name.
For @version – Enter the date you started writing the class in MM/DD/YYYY format.
A single line comment on each element needed for the assignment.
Significant variables descriptions.
No “loop” variables. a, b, c, x, y, z, etc.
public class Loan {
private double annualInterestRate;
private int numberOfYears;
private double loanAmount;
private java.util.Date loanDate;
/** Default constructor */
public Loan() {
this(2.5, 1, 1000);
}
/** Construct a loan with specified annual interest rate,
number of years, and loan amount
*/
public Loan(double annualInterestRate, int numberOfYears,
double loanAmount) {
this.annualInterestRate = annualInterestRate;
this.numberOfYears = numberOfYears;
this.loanAmount = loanAmount;
loanDate = new java.util.Date();
}
/** Return annualInterestRate */
public double getAnnualInterestRate() {
return annualInterestRate;
}
/** Set a new annualInterestRate */
public void setAnnualInterestRate(double annualInterestRate) {
this.annualInterestRate = annualInterestRate;
}
/** Return numberOfYears */
public int getNumberOfYears() {
return numberOfYears;
}
/** Set a new numberOfYears */
public void setNumberOfYears(int numberOfYears) {
this.numberOfYears = numberOfYears;
}
/** Return loanAmount */
public double getLoanAmount() {
return loanAmount;
}
/** Set a newloanAmount */
public void setLoanAmount(double loanAmount) {
this.loanAmount = loanAmount;
}
/** Find monthly payment */
public double getMonthlyPayment() {
double monthlyInterestRate = annualInterestRate / 1200;
double monthlyPayment = loanAmount * monthlyInterestRate / (1 -
(1 / Math.pow(1 + monthlyInterestRate, numberOfYears * 12)));
return monthlyPayment;
}
/** Find total payment */
public double getTotalPayment() {
double totalPayment = getMonthlyPayment() * numberOfYears * 12;
return totalPayment;
}
/** Return loan date */
public java.util.Date getLoanDate() {
return loanDate;
}
}
Loan Comparison Loan Amount 10000 Number of Years 5 Interest Rate Monthly Payment Total Payment $188.71 5.000 $11,322.74 $11,357.13 5.125 $189.28 $189.85 $11,391.59 5.250 $190.43 $11,426.11 5.375 $191.01 $11,460.69 5.500 $11,495.34 $191.58 5.625 $192.16 $11,530.06 5.750 $11,564.83 $192.74 5.875 6.000 $193.32 $11,599.68 Show TableSolution
Hi
Please find the modified code for the java code for loan payment calculator .
import java.text.NumberFormat;
import java.util.Scanner;
public class LoanPay {
private double annualInterestRate;
private int numberOfYears;
private double loanAmount;
private java.util.Date loanDate;
/** Default constructor */
public Loan() {
this(2.5, 1, 1000);
}
/** Construct a loan with specified annual interest rate,
number of years, and loan amount
public LoanPay(double annualInterestRate, int numberOfYears,
double loanAmount) {
this.annualInterestRate = annualInterestRate;
this.numberOfYears = numberOfYears;
this.loanAmount = loanAmount;
loanDate = new java.util.Date();
}
/** Return annualInterestRate */
public double getAnnualInterestRate() {
return annualInterestRate;
}
/** Set a new annualInterestRate */
public void setAnnualInterestRate(double annualInterestRate) {
this.annualInterestRate = annualInterestRate;
}
/** Return numberOfYears */
public int getNumberOfYears() {
return numberOfYears;
}
/** Set a new numberOfYears */
public void setNumberOfYears(int numberOfYears) {
this.numberOfYears = numberOfYears;
}
/** Return loanAmount */
public double getLoanAmount() {
return loanAmount;
}
/** Set a newloanAmount */
public void setLoanAmount(double loanAmount) {
this.loanAmount = loanAmount;
}
/** Find monthly payment */
public double getMonthlyPayment() {
double monthlyInterestRate = annualInterestRate / 1200;
double monthlyPayment = loanAmount * monthlyInterestRate / (1 -
(1 / Math.pow(1 + monthlyInterestRate, numberOfYears * 12)));
return monthlyPayment;
}
/** Find total payment */
public double getTotalPayment() {
double totalPayment = getMonthlyPayment() * numberOfYears * 12;
return totalPayment;
}
/** Return loan date */
public java.util.Date getLoanDate() {
return loanDate;
}
}
public static void main(String[] args) {
/**Scanner is a great class for getting */
Scanner scanner = new Scanner(System.in);
/**Prompt user for details of loan */
System.out.print(\"Enter loan amount: \");
nt loanAmount = scanner.nextInt();
System.out.print(\"Enter loan term (in years): \");
int termInYears = scanner.nextInt();
System.out.print(\"Enter interest rate: \");
double interestRate = scanner.nextDouble();
//**Display details of loan */
double monthlyPayment = calculateMonthlyPayment(loanAmount, termInYears, interestRate);
System.out.println(\"Loan Amount: \"+
currencyFormat.format(loanAmount));
System.out.println(\"Loan Term: \"+
termInYears+\" years\");
System.out.println(\"Interest Rate: \"+
interestFormat.format(interestRate));
System.out.println(\"Monthly Payment: \"+
currencyFormat.format(monthlyPayment));
System.out.println(\"Total Payment: \"+
currencyFormat.format(monthlyPayment));
}
}




