Modify java program-display the mortgage payment amount


Discuss the below:

Q: Modify the Java Programming so that it will display the mortgage payment amount for each loan and then list the loan balance and interest paid for each payment over the term of the loan. Use loops to prevent lists from scrolling off the screen.

Actual Problems:

Write the program in Java (without a graphical user interface) and have it calculate the payment amount for 3 mortgage loans:( with the default loan of $200000)

7 year at 5.35%

15 year at 5.5%

30 year at 5.75%

Use an array for the different loans. Display the mortgage payment amount for each loan and then list the loan balance and interest paid for each payment over the term of the loan. Use loops to prevent lists from scrolling off the screen

import java.math.*;
import java.text.*;

class MortgageCalculator4 {
public static void main(String arguments[]) {

//Program Variables using array
double []terms = {84,180,360};
double []Rates = {0.0535, 0.055, 0.0575};
double loan = 200000;

double term, interestRate; //Temporary variables to make things generic and clearer

DecimalFormat df = new DecimalFormat("$###,###.00"); //Formatting the output

//for each term and Rate starting from the first location of each array terms[] and Rates[]
for (int i=0;i //Calculates the Payment per month to be paid under mortgage scheme One
interestRate=Rates[i]; //take value from the array Rates[] to a temporary variable
term=terms[i]; //take value from the array terms[] to a temporary variable
double monthlyRate = (interestRate/12); //derive the monthly interest rate
//calculate the discount factor
double discountFactor = (Math.pow((1 + monthlyRate), term) -1) / (monthlyRate * Math.pow((1 + monthlyRate), term));
double payment1 = loan / discountFactor; //calculate payable amount per month
//Output for mortage scheme One
System.out.println("The Loan amount is:"+df.format(loan)+"\n");
System.out.println("The intrest rate is:"+interestRate*100+"%");
System.out.println("The term of the loan is:"+term/12+" years.");
System.out.println("Monthly Payment Amount: " + df.format(payment1)+"\n");
}
} //main ends here
} //class MortgageCalculator4 ends here

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Modify java program-display the mortgage payment amount
Reference No:- TGS01935414

Now Priced at $25 (50% Discount)

Recommended (92%)

Rated (4.4/5)