Hello, I am in a Java Course and my instructor said my first 2 loans the calculations are wrong. and that I need to have this in an ARRAY also.

Any help would be appreciated.

```
import java.text.*;
import java.io.IOException;
class javamortgage //program class name
{
public static void main(String[] args) throws IOException
{
double amount,moPay,totalInt,principal = 200000; //monthly payment, total interest and principal
double rate [ ] = {.0535, .055, .0575}; //the three interest rates
int [ ] term = {7,15,30}; //7, 15 and 30 year term loans
int time,ratePlace = 0,i,pmt=1,firstIterate = 0,secondIterate = 0,totalMo=0;
char answer,test;
boolean validChoice;
System.in.skip(System.in.available()); //clear the stream for the next entered character
do
{
validChoice = true;
System.out.println("What Choice would you Like\n");
System.out.println("1-Interest rate of 5.35% for 7 years?"); //just as it reads for each to select from
System.out.println("2-Interest rate of 5.55% for 15 years?");
System.out.println("3-Interest rate of 5.75% for 30 years?");
System.out.println("4-Quit");
answer = (char)System.in.read();
if (answer == '1') //7 yr loan at 5.35%
{
ratePlace = 0;
firstIterate = 4;
secondIterate = 21;
totalMo= 84;
}
else if (answer == '2') //15 yr loan at 5.55%
{
ratePlace = 1;
firstIterate = 8;
secondIterate = 24;
totalMo = 180;
}
else if (answer == '3') //30 yr loan at 5.75%
{
ratePlace = 2;
firstIterate = 15;
secondIterate = 24;
totalMo = 360;
}
else if (answer == '4') //exit or quit
{
System.exit(0);
}
else
{
System.in.skip(System.in.available()); //validates choice
System.out.println("Invalid choice, try again.\n\n");
validChoice = false;
}
}while(!validChoice); //when a valid choice is found calculate the following, ! means not, similar to if(x != 4)
for(int x = 0; x < 25; x++)System.out.println();
amount = (principal + (principal * rate[ratePlace] * term[ratePlace] ));
moPay = (amount / totalMo);
totalInt = (principal * rate[ratePlace] * term[ratePlace]);
DecimalFormat df = new DecimalFormat("0.00");
System.out.println("The Interest on $" + (df.format(principal) + " at " + rate[ratePlace]*100 +
"% for a term of "+term[ratePlace]+" years is \n" +"$"+ (df.format(totalInt) +" Dollars\n")));
System.out.println("\nThe total amount of loan plus interest is $"+(df.format(amount)+" Dollars.\n"));
System.out.println("\nThe Payments spread over "+term[ratePlace]* 12+" months would be $"+
(df.format (moPay) + " Dollars a month\n\n"));
System.in.skip(System.in.available());
System.out.println("\nWould you like to see a planned payment schedule? y for Yes, or x to Exit");
answer = (char)System.in.read();
if (answer == 'y')
{
System.out.println((term[ratePlace]*12) + " monthly payments:");
String monthlyPayment = df.format(moPay);
for (int a = 1; a <= firstIterate; a++)
{
System.out.println(" Payment Schedule \n\n ");
System.out.println("Month Payment Balance\n");
for (int b = 1; b <= secondIterate; b++)
{
amount -= Double.parseDouble(monthlyPayment);
System.out.println(""+ pmt++ +"\t"+ monthlyPayment + "\t"+df.format(amount));
}
System.in.skip(System.in.available());
System.out.println(("This Page Is Complete Press [ENTER] to Continue"));
System.in.read();
}
}
}
}
```