Can't figure out my error..
I have to write a Mortgage Program that will show interest paid over 30 years.
I am getting the following error when running the program.
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
at MortgageProject.main(MortgageProject.java:33)
Thanks in advanced for your help.
/*
* MortgageProject.java
* This program is to display the mortgage payment from hard coded numbers from arrays
* without accepting any input from users. Then it is to list the balance
* and interest paid for each payment or the entire loan.
*/
import java.text.DecimalFormat;//needed to set the decimal point place
import javax.swing.JOptionPane;//needed to make the program pause
import java.io.*;
import java.util.Date;
class MortgageProject
{
publicstaticvoid main(String[]args)throws Exception
{
Date currentDate =new Date();//Date constructor
int[] MonthPayment ={30};//declares how many years
double Monthly = 0;//delcares the variable for the mortgage payment
double Amount = 200000;//declares how much the loan is for
double[] MonthInt ={5.75};//declares the interest rate
double PaidInt;//paid interest monthly
double OutStand;//monthly balance
int MonthTerm;//number of payments
char enter;
DecimalFormat TwoDec =new DecimalFormat("0.00");//decimal format for ouput
for (int i=0; i<3;i++)//loop for each array
{
MonthTerm=MonthPayment[i]*12;//monthterm will now equal the number of payments
MonthInt[i]=MonthInt[i]/100/12;//monthint will now equal the MONTHLY interest rate
//following determines the mortgage payment
Monthly = (Amount*Math.pow((1+MonthInt[i]),MonthTerm)*MonthInt[i])/
(Math.pow((1+MonthInt[i]),MonthTerm)-1);
System.out.println("\t" + currentDate);
System.out.println();
System.out.println("\n\tTerm of Loan:"+MonthPayment[i]+" yrs");
System.out.println("\n\tInterest Rate of Loan:"+TwoDec.format(MonthInt[i]*100*12)+"%");
System.out.println("\n\tMonthly Payment:$"+TwoDec.format(Monthly));
System.out.println();
OutStand=Amount;
for (int m=1;m<=MonthTerm;m++)//loop to display all monthly data
{
if (m%11==0)//loop to display 11 lines before requesting the enter key
{
System.out.println("\nPress the Enter Key to Continue");//tells user to hit enter key to continue
enter=(char)System.in.read();
System.in.read();
}
PaidInt=OutStand*MonthInt[i];//calculates the amount paid to interest
OutStand=OutStand-Monthly+PaidInt;//adjust the outstanding balance for each month
System.out.println(m+"\t"+"$"+TwoDec.format(PaidInt)+"\t\t"+"$"+TwoDec.format(OutStand));
}
}
}
}

