/** *Week 4 Assignment- Diane Beck * Write the program in Java (without graphical user interface) and have it * calculate the payments amount for 3 mortgage loans: -7 years at 5.35%, -15 years at 5.5%, *-30 years at 5.75%. Use and array for the differents loans. Display the mortgage payment *amount for each loan. * * * Student: Diane Beck */ import java.util.Scanner; import java.lang.Math; import java.text.DecimalFormat; import java.io.IOException;//imports code for handling of Enter key input import java.io.BufferedReader; import java.io.InputStreamReader; class MortgageLoans { public static void main (String[] args) //start main() function { //declare variables array double mortgageCalculator1[] = new double[6]; double MortgageCalculator2[] = new double[6]; double MortgageCalculator3[] = new double[6]; double Payment; //construct the array //mortgageCalculator1 = new double[6]; //mortgageCalculator2 = new double[6]; //mortgageCalculator3 = new double[6]; double loan = 200000; double term1 = 360;//*360 month for 30 year mortgage double interestRate1 = 0.0575;//*5.75% 5.75/100interest rate 30 year mortgage double monthlyRate1 = (interestRate1/12); double term2 = 84;//*7 year mortgage loan double interestRate2 = 0.0535;//*5.35 5.35/100interest rate 7 year mortgage double monthlyRate2 = (interestRate2/12);//*rate calculation on 7 year mortgage loan double term3 = 180;// 15 year mortgage double interestRate3 = 0.0550;//*5.5 5.5/100 interest rate on 15 year mortgage double monthlyRate3 = (interestRate3/12);//*monthlyRate for 15 year mortgage //Discount factr calculator for the three loans double discountFactor1 = (Math.pow((1 + monthlyRate1),term1) -1/(monthlyRate1 * Math.pow((1 + monthlyRate1),term1))); double discountFactor2 = (Math.pow((1 + monthlyRate2),term2) -1/(monthlyRate2 * Math.pow((1 + monthlyRate2),term2))); double discountFactor3 = (Math.pow((1 + monthlyRate3),term3) -1/(monthlyRate3 * Math.pow((1 + monthlyRate3),term3))); double payment1 = loan/discountFactor1;//*Rate Calculation for 30 year mortgage double payment2 = loan/discountFactor2;//*Rate Calculation for 7 year mortgage double payment3 = loan/discountFactor3;//*Rate Calculation for 15 year mortgage //loop while not done while(loan>0) { java.text.DecimalFormat dfm = new java.text.DecimalFormat(",###.00"); System.out.println("Your monthly payment is $" + dfm.format(payment) + "cents"); //loop while done if(loan>0) { payment1 = loan/discountFactor1;//*Rate Calculation payment2 = loan/discountFactor2;//*Rate Calculation payment3 = loan/discountFactor3;//*Rate Calculation } else payment1 = payment/discountFactor1;//Rate Calculation payment2 = payment/discountFactor2;//Rate Calculation payment3 = payment/discountFactor3;//Rate Calculation } //Output } }

Where did I go wrong.

Admin Edit: Please use code tags when posting your code. Code tags are used like so =>

Thanks,

PsychoCoder