Not sure why it isnt working or what else I need to do. so any help would be great thanks
Extend your Java Project with the following items:
o Write the program in Java (without a graphical user interface) and have it
calculate the payment amount for 3 mortgage loans:
7 year at 5.35%
15 year at 5.5%
30 year at 5.75%
o 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.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package MortagePaymentCalculator;
/**
* @Author: JDonaldson
* Date Written: 2/26/2011
* Program Description: Week 3 Assignment
*/
import static java.lang.Math.*; //Import static class members
import java.text.DecimalFormat; //Import for decimal points
public class Test3
{
public static void main (String [] args)
{
int i = 0;
double LoanAmount = 200000;
double LoanBalance = 0;
double InterestPaid = 0;
int LoanTerm[] = {84, 180, 360};
double Interest[] = {.0535, .0550, .0575};
double MonthlyPayment = 0;
DecimalFormat Currency = new DecimalFormat ("$###,###.##");
DecimalFormat Format = new DecimalFormat("0.##");
if (i == 0)
{
MonthlyPayment = LoanAmount * (((Interest[2]/12) * Math.pow((1 + (Interest[2]/12)), LoanTerm[0])) / (Math.pow((1 + (Interest[2]/12)), LoanTerm[2]) - 1));
LoanBalance = LoanAmount - MonthlyPayment;
InterestPaid = MonthlyPayment * Interest[0];
//Displays calculations for first loan
System.out.println("McBride Financial Services Mortgage Calculator");
System.out.println("The loan amount is: $200,000");
System.out.println("The term of the loan is:" + LoanTerm[0]);
System.out.println("The monthly payment is: $" + Format.format(MonthlyPayment));
System.out.println("The loan balance is: $" + Format.format(LoanBalance));
System.out.println("The interest paid is: $" + Format.format(InterestPaid));
System.out.println();
}
if (i == 1)
{
MonthlyPayment = LoanAmount * (((Interest[1]/12) * Math.pow((1 + (Interest[1]/12)), LoanTerm[1])) / (Math.pow((1 + (Interest[1]/12)), LoanTerm[1]) - 1));
LoanBalance = LoanAmount - MonthlyPayment;
InterestPaid = MonthlyPayment * Interest[1];
//Displays mortgage calculator
System.out.println("McBride Financial Services Mortgage Calculator");
System.out.println("The loan amount is: $200,000");
System.out.println("The term of the loan is:" + LoanTerm[1]);
System.out.println("The monthly payment is: $" + Format.format(MonthlyPayment));
System.out.println("The loan balance is: $" + Format.format(LoanBalance));
System.out.println("The interest paid is: $" + Format.format(InterestPaid));
System.out.println();
}
if (i == 2)
{
MonthlyPayment = LoanAmount * (((Interest[2]/12) * Math.pow((1 + (Interest[2]/12)), LoanTerm[2])) / (Math.pow((1 + (Interest[2]/12)), LoanTerm[2]) - 1));
LoanBalance = LoanAmount - MonthlyPayment;
InterestPaid = MonthlyPayment * Interest[2];
//Displays mortgage calculator
System.out.println("McBride Financial Services Mortgage Calculator");
System.out.println("The loan amount is: $200,000");
System.out.println("The term of the loan is:" + LoanTerm[2]);
System.out.println("The monthly payment is: $" + Format.format(MonthlyPayment));
System.out.println("The loan balance is: $" + Format.format(LoanBalance));
System.out.println("The interest paid is: $" + Format.format(InterestPaid));
System.out.println();
}
for (int a=1;a<361;a++) //begin loop to show 360 payments
{
InterestPaid = (LoanAmount * Interest[2]);
double principalPaid = MonthlyPayment - InterestPaid;
LoanAmount = LoanAmount - principalPaid;
System.out.println("\nMonthly Payment " + a + " = " + Currency.format (MonthlyPayment));
System.out.println("Loan Balance = " + Currency.format (LoanBalance));
System.out.println("Interest Paid = " + Currency.format(InterestPaid));
if (a%6 == 0) // pause display between screens
{
try
{
Thread.sleep(1500);
}
catch(InterruptedException ie) {}
}
}
}
}