I am stuck again, I was able to complete last week's assignment without having to post, just so you guys don't think I'm a lost cause! :) I need to allow the user to input loan amount, term, and interest rate before calculating the monthly payment and showing the table. This is what I have so far. I am getting between two and three errors that I cannot figure out. Any help and/or hints are greatly appreciated.

```
/*
MortgageProgramWK4b.java
This program will accept user input for the loan amount,
interest rate, and term of the loan. Then calculate and
display the monthly mortgage payment amount, Followed by,
listing the loan balance and interest paid for
each payment over the term of the loan.
*/
import java.math.*;
import java.io.*;
public static void main(String[] args)throws Exception
{
//local objects
MortgageProgramWK4b mortgageCalc = new MortgageWK4b();
DecimalFormat df = new DecimalFormat("###,##0.00");
DecimalFormat numDf = new DecimalFormat("000");
int numOfYears;
double annualInterest;
double principal;
double monthlyPayment;
//Display Title
System.out.println("Mortgage Calculator");
System.out.println();
//Get User Input of principal
int principal = readInterger("Please enter the pricipal amount of the loan." );
//Get User Input of rate
int annualInterest = readInterger("Please enter the pricipal amount of the loan." );
//Get User Input of Term
int numOfYears = readInterger("Please enter the pricipal amount of the loan." );
double monthlyInterest = annualInterest/(12*100);!
int totalNumOfMonths = numOfYears*12;
System.out.println("Payment# LoanBalance InterestPaid");
int monthCounter=1;
for(; totalNumOfMonths>0; totalNumOfMonths--){
//first get the monthly payment...
double monthlyPayment = mortgageCalc.getMortgageAmount(principal,monthlyInterest,totalNumOfMonths);
double monthlyPrincipal = mortgageCalc.getMonthlyPrincipal(monthlyPayment,monthlyInterest,principal);
principal-=monthlyPrincipal;
System.out.println(numDf.format(monthCounter) + " " +df.format(principal)+ " " +df.format((monthlyPayment-monthlyPrincipal)));
monthCounter++;
if(monthCounter%25==0)sleep(1000); // this will hesitate...
}
}
public double getMortgageAmount(double principal, double monthlyInterest, int numOfMonths){
// Monthly payment formula: M = P x (J/(1-(1+J)^-N));
// M = P * ( J / (1 - (1 + J) ** -N));
// source: http://www.hughchou.org/calc/formula.html
double monthlyPayment = (double)(principal*(monthlyInterest / (1-(Math.pow((1+monthlyInterest),(numOfMonths*-1))))));
return monthlyPayment;
}
//calculate the monthly interst using simple interest.
public double getMonthlyPrincipal(double monthlyPayment, double monthlyInterest, double remainingPrincipal){
return monthlyPayment - (remainingPrincipal * monthlyInterest);
}
// method to make the program sleep (hesitate) for a give time (in milliseconds)..
public static void sleep(long milliseconds){
try{
Thread.sleep(milliseconds);
}catch(Exception e){
}
}
}
```

_____________________________

This is the other way I tried it... I am getting the same three errors both ways...

```
/*
MortgageProgramWK4a.java
This program will accept user input for the loan amount,
interest rate, and term of the loan. Then calculate and
display the monthly mortgage payment amount, Followed by,
listing the loan balance and interest paid for
each payment over the term of the loan.
*/
import java.math.*;
import java.io.*;
public static void main(String[] args)throws Exception
{
//local objects
MortgageProgramWK4a mortgageCalc = new MortgageProgramWK4a();
DecimalFormat df = new DecimalFormat("###,##0.00");
DecimalFormat numDf = new DecimalFormat("000");
int numOfYears;
double annualInterest;
double principal;
double monthlyPayment;
//Display Title
System.out.println("Mortgage Calculator");
System.out.println();
//Get User Input of principal
System.out.println("Please enter the loan amount: ");
principal = (double)System.in.read();System.in.read();System.in.read();
//Get User Input of rate
System.out.println("Please enter the interest rate: ");
annualInterest= (int)System.in.read();System.in.read();System.in.read();
//Get User Input of Term
System.out.println("Please enter the term of the loan in years: ");
numOfYears = (int)System.in.read();System.in.read();System.in.read();
int numOfYears = System.in();
double monthlyInterest = annualInterest/(12*100);!
int totalNumOfMonths = numOfYears*12;
System.out.println("Payment# LoanBalance InterestPaid");
int monthCounter=1;
for(; totalNumOfMonths>0; totalNumOfMonths--){
//first get the monthly payment...
double monthlyPayment = mortgageCalc.getMortgageAmount(principal,monthlyInterest,totalNumOfMonths);
//now get the monthly principal in the payment...
double monthlyPrincipal = mortgageCalc.getMonthlyPrincipal(monthlyPayment,monthlyInterest,principal);
principal-=monthlyPrincipal;
System.out.println(numDf.format(monthCounter) + " " +df.format(principal)+ " " +df.format((monthlyPayment-monthlyPrincipal)));
monthCounter++;
if(monthCounter%25==0)sleep(1000); // this will hesitate...
}
}
public double getMortgageAmount(double principal, double monthlyInterest, int numOfMonths){
// Monthly payment formula: M = P x (J/(1-(1+J)^-N));
// M = P * ( J / (1 - (1 + J) ** -N));
// source: http://www.hughchou.org/calc/formula.html
double monthlyPayment = (double)(principal*(monthlyInterest / (1-(Math.pow((1+monthlyInterest),(numOfMonths*-1))))));
return monthlyPayment;
}
//calculate the monthly interst using simple interest.
public double getMonthlyPrincipal(double monthlyPayment, double monthlyInterest, double remainingPrincipal){
return monthlyPayment - (remainingPrincipal * monthlyInterest);
}
// method to make the program sleep (hesitate) for a give time (in milliseconds)..
public static void sleep(long milliseconds){
try{
Thread.sleep(milliseconds);
}catch(Exception e){
}
}
}
```

I am getting the same three errors, all of them are saying "class" or "interface" expected. Again, any help is really appreciated.