I am new to java and having problems with this last error.
Code:
package prg420.week5; // adds the package
import java.text.DecimalFormat; // Import the java. text for formating
import java.lang.Math; //Import the java math
class Calculator //creates and start this class
{
public class months<i> {
public void add (i) ; {
this.i = i;
}
public i get() {
return i;
}
}
public void MortArray() //creates array
{
java.text.DecimalFormat df2 = new java.text.DecimalFormat(",###.00"); // formats numbers to display only two decimal places
// declare variables
double monPayment [] = new double [3] ; // monthly payment
double monIntRate [] = new double [2] ; // monthly interest rate
int months[] = new int [1] ; // length of loan in months
double[][] mortgage =
{{200000, 84, 5.35, 0.0},
{200000, 180, 5.50, 0.0},
{200000, 360, 5.75, 0.0}};
//Using an array
months = months[1];
monIntRate = (mortgage[i][2]/12)/100;
monPayment = (mortgage[i][0]*monIntRate)/(1-Math.pow(1+monIntRate, -months));
System.out.println ("\n\nMortgage amount is \t" + df2.format(mortgage[i][0]));
System.out.println ("Terms of mortgage is \t " + mortgage[i][1] + "months");
System.out.println ("Interest rate is \t " + mortgage[i][2] + "%");
System.out.println ("Monthly mortgage payment \t$" + df2.format(monPayment));
if(months == 1){
System.out.println("\n\n\nPayment\t\tPrincipal\t\tInterest\tPrincipal");
System.out.println("Month #\t\tPayment\t\t\tPayment\t\tBalance");
System.out.println("------- \t---------\t\t---------\t---------");
}
System.out.println();
System.out.println(months+ "\t\t$" + df2.format(monPayment) +
" \t\t$" + df2.format(monthlyIntPay) +
"\t\t$" + df2.format(balance));
{
System.out.print("\nPress Enter To Continue showing payments for for Loan No. " + (i+1)+":");
byte[] buffer = new byte[12];
System.in.read(buffer);
counter = 0;
if(months[i]){
System.out.println("\n\n\nMonths\t\tPrincipal\t\tInterest\tPrincipal");
System.out.println("\t\tPayment\t\t\tPayment\t\tBalance");
System.out.println("---------\t---------\t\t---------\t---------");
for(int i=0; i<3; i++) // starts loop
{for (int count = 1; count < 360; count ++)
{
if (count == 15)
break;
};
System.out.println ("\n\nMortgage amount is \t" + df2.format(mortgage[i][0]));
System.out.println ("Terms of mortgage is \t " + mortgage[i][1] + "months");
System.out.println ("Interest rate is \t " + mortgage[i][2] + "%");
System.out.println ("Monthly mortgage payment \t$" + df2.format(monPayment));
}
}
}
}
public class MortCalculator
{
public static void main( String args[] ) //Create main method
{
Calculator CalculatorA = new Calculator(); //Create object with instance of MCalc
CalculatorA.MortArray(); //Call array
int count=0;
// these conditional statements cause the results to pause
if(count == 15)
{
count = 0;
try
{
Thread.sleep(5000); // pause to last five seconds
} //end thread
catch (InterruptedException e)
{
}
} // end if
else
{
count++;
} // end else
}
}
}
What do I need to do to fix this final error?