mannyfresco
asked on
mortgage calculator
i cant make this prog compile i have one error.
import java.math.*;
import java.text.*;
import java.util.*;
public class mortgage {
static NumberFormat n = NumberFormat.getCurrencyIn stance();
static int yterm = 30; // Variable for length of term in years
static double price = 200000; // Variable for total amount of mortgage
static double rate = 5.75; // Variable for interest rate
static double mrate = rate/100;
static double payment = price*((mrate)/(12)+((mrat e)/(12))/( Math.pow(( 1+(mrate)/ 12),(yterm *12))-1));
public static void main(String[] args) throws Exception{
int term = 360;
double interestDue, amtApplied;
while (term > 0) {
if(term == 300)
break;
interestDue = (price * (rate/100)) / 12;
amtApplied = payment - interestDue;
price = price - amtApplied;
System.out.println("Paymen t # " + term
+ " Principle=" + n.format(amtApplied)
+ " Interest=" + n.format(interestDue)
+ " Balance=" + n.format(price));
--term;
return --term;
}
while (term > 0) {
if(term == 240)
break;
interestDue = (price * (rate/100)) / 12;
amtApplied = payment - interestDue;
price = price - amtApplied;
System.out.println("Paymen t # " + term
+ " Principle=" + n.format(amtApplied)
+ " Interest=" + n.format(interestDue)
+ " Balance=" + n.format(price));
--term;
return --term;
reach end of file while parsing return --term:
import java.math.*;
import java.text.*;
import java.util.*;
public class mortgage {
static NumberFormat n = NumberFormat.getCurrencyIn
static int yterm = 30; // Variable for length of term in years
static double price = 200000; // Variable for total amount of mortgage
static double rate = 5.75; // Variable for interest rate
static double mrate = rate/100;
static double payment = price*((mrate)/(12)+((mrat
public static void main(String[] args) throws Exception{
int term = 360;
double interestDue, amtApplied;
while (term > 0) {
if(term == 300)
break;
interestDue = (price * (rate/100)) / 12;
amtApplied = payment - interestDue;
price = price - amtApplied;
System.out.println("Paymen
+ " Principle=" + n.format(amtApplied)
+ " Interest=" + n.format(interestDue)
+ " Balance=" + n.format(price));
--term;
return --term;
}
while (term > 0) {
if(term == 240)
break;
interestDue = (price * (rate/100)) / 12;
amtApplied = payment - interestDue;
price = price - amtApplied;
System.out.println("Paymen
+ " Principle=" + n.format(amtApplied)
+ " Interest=" + n.format(interestDue)
+ " Balance=" + n.format(price));
--term;
return --term;
reach end of file while parsing return --term:
You'll probably need another } to close the last while loop too.
you need "}}}" after the last >>return --term,
remove both the return statement,
remove both the return statement,
ASKER
thanks now i have to make this mortgage calculator amortize.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Even if you put that you will get another error, as you are returning int from a function that doesn't return anything.
consider breaking this function into parts.