Hey all,
I have been working with this for about 4 days and pulling my hair out.
I can't figure out why I am getting the error messages in my code, when I compile.
Here is my code.
// Week3 Dwight Welsh
import java.text.DecimalFormat;
public class Mortgage
{
public static void main(String args[]) throws Exception
{
// declare and construct variables
double loanAmt = 200000; // principal loan amount
double loanTerm = 360; // loan term for 30 years
double loanYears = 30; // indicates the loan term in years
double intRate = 5.75; // interest rate 30 years
double newIntRate; // displays interest rate calculation
double monthlyPay = 0; // displays monthly payment calculation
DecimalFormat money = new DecimalFormat("$0.00"); // displays mortgage in decimal format
DecimalFormat money2 = new DecimalFormat("0.00%"); // displays interest rate in decimal format
// displays messages to indicate purpose of program and conditions in the console window
System.out.println();
System.out.println("Welcome to the Mortgage Payment Calculator");
System.out.println();
System.out.println("This program will calculate the mortgage payments for a $" + loanAmt);
System.out.println("with the following loan terms and interest rates: 30 years @ 5.75%");
System.out.println();
System.out.println("The results are as follows:");
{
intRate = (intRate /12 * .01);
monthlyPay = loanAmt * intRate / (1 - Math.pow(1 + intRate, - loanTerm));
// displays results for loan in the console window
System.out.println();
System.out.println("The mortgage payment for a $" + loanAmt + " loan for " + (loanTerm /12) + " years at");
System.out.println("a " + (money2.format(intRate) + " interest rate = " + (money.format(monthlyPay))));
//loan <-- calculate loan
for (i) //<-- 1 through loan duration,
incrementing (i) //<-- i + 1 on each iteration)
(loan <-- loan - monthlyPayment)
System.out.println("Monthly payment" + i + ":" + monthlyPayment);
(end for)
}
}
}
and here are the error messages
O:\college stuff\PRG420 JAVA PROGRAMMING I\Ind Assign\Wk3\Mortgage.java:40: not a statement
for (i) //<-- 1 through loan duration,
^
O:\college stuff\PRG420 JAVA PROGRAMMING I\Ind Assign\Wk3\Mortgage.java:40: ';' expected
for (i) //<-- 1 through loan duration,
^
O:\college stuff\PRG420 JAVA PROGRAMMING I\Ind Assign\Wk3\Mortgage.java:40: ';' expected
for (i) //<-- 1 through loan duration,
^
O:\college stuff\PRG420 JAVA PROGRAMMING I\Ind Assign\Wk3\Mortgage.java:41: not a statement
incrementing (i) //<-- i + 1 on each iteration)
^
O:\college stuff\PRG420 JAVA PROGRAMMING I\Ind Assign\Wk3\Mortgage.java:43: ')' expected
(loan <-- loan - monthlyPayment)
^
O:\college stuff\PRG420 JAVA PROGRAMMING I\Ind Assign\Wk3\Mortgage.java:47: ')' expected
(end for)
^
O:\college stuff\PRG420 JAVA PROGRAMMING I\Ind Assign\Wk3\Mortgage.java:47: not a statement
(end for)
^
O:\college stuff\PRG420 JAVA PROGRAMMING I\Ind Assign\Wk3\Mortgage.java:47: illegal start of expression
(end for)
^
O:\college stuff\PRG420 JAVA PROGRAMMING I\Ind Assign\Wk3\Mortgage.java:47: ';' expected
(end for)
^
O:\college stuff\PRG420 JAVA PROGRAMMING I\Ind Assign\Wk3\Mortgage.java:50: reached end of file while parsing
}
^
10 errors
Tool completed with exit code 1
Thanks for any help.
IKE