Solved

mortgage calculator

Posted on 2006-07-17
5
313 Views
Last Modified: 2010-03-31
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.getCurrencyInstance();

    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)+((mrate)/(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("Payment # "  + 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("Payment # "  + term
            + "  Principle=" + n.format(amtApplied)
            + "  Interest=" + n.format(interestDue)
            + "  Balance=" + n.format(price));
        --term;
   return --term;

reach end of file while parsing return --term:    
0
Comment
Question by:mannyfresco
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 23

Expert Comment

by:Ajay-Singh
ID: 17127500
You can missing closing brackets "}}" after "return --term;".

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.
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 17128437
You'll probably need another } to close the last while loop too.
0
 
LVL 10

Expert Comment

by:mukundha_expert
ID: 17128759
you need "}}}" after the last  >>return --term,
remove both the return statement,





0
 

Author Comment

by:mannyfresco
ID: 17138042
thanks now i have to make this mortgage calculator amortize.
0
 
LVL 10

Accepted Solution

by:
mukundha_expert earned 500 total points
ID: 17138060
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question