This is for a class, and I already turned in my assignment. I'm getting the correct response from my script, but I'm getting the message:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1

at mortgage.calculator.MortgageCalculator.main(Mortga geCalculator.java:40)

Java Result: 1

I've looked at examples, and understand that I've defined the parameters of something to be too small, but am so new to Java that I don't know where or how to fix it. I think this is indicating an issue in line 40?

I used the code symbols, but the line numbers went away when I edited. I bolded line 40.Code:`/**`

* PRG420 Week 2

* Katie Young

* SR-mf-003, Mortgage Payment Calculator

*/

package mortgage.calculator;

//The java.io package provides for system input and output through data streams

import java.io.*;

//A subclass of the NumberFormat used to format numbers in Java programs

import java.text.DecimalFormat;

public class MortgageCalculator

//The main function for the mortgage calculator

public static void main(String[] args) throws IOException

{

//Declaring and constructing variables, each field can be expanded to allow multiple variables

//Term of mortgage in years

int [] iTerm = {360};

//Interest rate

double [] dInterest = {5.25};

//Amount of loan

double dPayment, dRate, dAmount = 200000, dMonthlyInterest,dMonthlyPrincipal, dMonthlyBalance;

DecimalFormat twoDigits = new DecimalFormat("$#,000.00");

//Loop for the varying Mortgage Rates and Payments

int p;

for (p = 0; p <= 2; p ++)

{

//Calculation for the monthly mortgage payment

//Calculations Retrieved from http://www.1728.com/loanform.htm on 8/15/08

[B]dRate = dInterest[p] / 1200;[/B]dPayment = (dAmount * dRate) / (1 - Math.pow(1 / (1 + dRate), iTerm[p]));

dMonthlyInterest = (dAmount / 12) * (dInterest[p] / 100);

dMonthlyPrincipal = (dPayment - dMonthlyInterest);

dMonthlyBalance = (dAmount - dMonthlyPrincipal);

int nbYear = iTerm[p] / 12;

System.out.println();

System.out.println("Your Monthly Payment for a " + nbYear +" year loan of "

+ "$200,000 at " + dInterest[p]+ "% is: " + twoDigits.format (dPayment));

System.out.println();

}

}

//function for the calculation of the interest into the loan payment

public double MonthlyInterest()

{

//Declaring Variables for interest on the loan

double dMonthlyInterest = 0.0;

double dAmount = 0.0;

double dInterest = 0.0;

//Calculation for monthly interest

dMonthlyInterest = (dAmount / 12) * (dInterest / 100);

return dMonthlyInterest;

}

//function for the calculation of the interest into the loan payment

public double monthlyInterest()

{

//Declaring Variables for interest on the loan

double dMonthlyInterest = 0.0;

double dAmount = 0.0;

double dInterest = 0.0;

//Calculation for monthly interest

dMonthlyInterest = (dAmount / 12) * (dInterest / 100);

return dMonthlyInterest;

}

//function of the calculation of the monthly principal for the loan payment

public static double monthlyPrincipal()

{

//Declaring Variables for monthly principal

double dMonthlyPrincipal = 0.0;

double dPayment = 0.0;

double dMonthlyInterest = 0.0;

//Calculations for monthly principal

dMonthlyPrincipal = (dPayment - dMonthlyInterest);

return dMonthlyPrincipal;

}

//function for the calculation of the monthy loan balance

public static double monthlyBalance()

{

//Declaring Variables for monthly loan balance

double dMonthlyBalance = 0.0;

double dAmount = 0.0;

double dMonthlyPrincipal = 0.0;

//Calculations for monthly loan balance

dMonthlyBalance = (dAmount - dMonthlyPrincipal);

return dMonthlyBalance;

}

}

Thank you,

Katie