Hello,
I am doing a homework assignment and I am getting an "illegal character" error and I don't understand. The assignment is to use an array to calculate three mortgage payments based on three differnt rates and terms in years.
Thanks in advance Y'all.
/* calculator program to fully amortize a 200k loan over 30 years ata rate of 5.75%
Created by: Andrew Johnson
Class: PGR420
Date: 07/23/2010
Purpose: This project displays the amortized monthly payment for loans below:
$200,000.00 loan over a 7 year term at 5.35 interest
$200,000.00 loan over a 15 year term at 5.5 interest
$200,000.00 loan over a 30 year term at 5.75 interest
*/
import static java.lang.Math.*;
import java.util.Date;
import java.awt.*;
import java.applet.*;
public class MortCalcWk5
{
public static void main(String[] args)
{
//Define variables and initialize them
int[] term = { 7, 15, 30 };//length of loan in years
double[] rate = { 5.35, 5.5, 5.75 }; //rate of the loan
for(int i = 0; i < term.length; i++) {
for(double j = 0; j < rate.length; j++)
double P = 200000.0; //principal, initial amount of loan
double I = rate[j]; //interest rate
double L = term[i]; //Length-time in years to pay the loan off
//define more variable to simplify
double J = I/(12*100); //monthly interest rate in decimal form
double N = L*12; // number of months which the loan is amortized
//define monthly payment variable
double M = P*(J/(1-pow((1+J), -N))); //$ amount of monthly payment
//display monthly payment
System.out.println("your monthly payment of the loan is");
System.out.println("$ " +round(M*100.00)/100.00);
}
}
}