Welcome to Dream.In.Code
Become a Java Expert!

Join 150,365 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,804 people online right now. Registration is fast and FREE... Join Now!




Java error

 
Reply to this topicStart new topic

Java error

greenhorn100
3 Feb, 2008 - 12:06 PM
Post #1

New D.I.C Head
*

Joined: 24 Jan, 2008
Posts: 7

I keep getting an error in my code... could anyone help?

/* Purpose:Write the program in Java (without a graphical user interface) and have it calculate the payment
amount for 3 mortgage loans:*/

CODE


import java.io.*;
import java.util.*;
import java.text.*;

//class header
public class MortgageCalculator2
{
    public static void main(String[] args){

            NumberFormat nf = NumberFormat.getCurrencyInstance();

            final double principleBalance = 200000;
            final double monthlyInterest;// = .0575/12;
            final double months;//= 12*30;


            String[] Array = new String[3];

            Array[0] = loan1;
            Array[1] = loan2;
            Array[2] = loan3;


            monthlyInterest = .0535/12;
            months = 12*7;
            String loan1 =(principleBalance*monthlyInterest)/(1-Math.pow(1 + monthlyInterest, -months));
                    //print out variables
            System.out.println("\t\tPrinciple or Loan Amount: " + principleBalance);
            System.out.println("\t\tInterest Rate: " + monthlyInterest);
            System.out.println("\t\tThe Term of Loan (in months): " + months);
            System.out.println("\t\tThe Monthly Payment is: " + nf.format(loan1));

            monthlyInterest = .0550/12;
            months = 12*15;
            String loan2 =(principleBalance*monthlyInterest)/(1-Math.pow(1 + monthlyInterest, -months));
                        //print out variables
            System.out.println("\t\tPrinciple or Loan Amount: " + principleBalance);
            System.out.println("\t\tInterest Rate: " + monthlyInterest);
            System.out.println("\t\tThe Term of Loan (in months): " + months);
            System.out.println("\t\tThe Monthly Payment is: " + nf.format(loan2));


            monthlyInterest = .0575/12;
            months = 12*30;
            String loan3 =(principleBalance*monthlyInterest)/(1-Math.pow(1 + monthlyInterest, -months));
            //print out variables
            System.out.println("\t\tPrinciple or Loan Amount: " + principleBalance);
            System.out.println("\t\tInterest Rate: " + monthlyInterest);
            System.out.println("\t\tThe Term of Loan (in months): " + months);
            System.out.println("\t\tThe Monthly Payment is: " + nf.format(loan3));
}



User is offlineProfile CardPM
+Quote Post

GWatt
RE: Java Error
3 Feb, 2008 - 12:37 PM
Post #2

human inside
Group Icon

Joined: 1 Dec, 2005
Posts: 2,360



Thanked: 31 times
Dream Kudos: 500
My Contributions
Not until you tell us what the error is.

[edit]
I am so betting that it has something to do with you not declaring the three strings loan1, loan2, loan3 before you use them.

This post has been edited by GWatt: 3 Feb, 2008 - 12:40 PM
User is online!Profile CardPM
+Quote Post

greenhorn100
RE: Java Error
3 Feb, 2008 - 12:58 PM
Post #3

New D.I.C Head
*

Joined: 24 Jan, 2008
Posts: 7

QUOTE(GWatt @ 3 Feb, 2008 - 01:37 PM) *

Not until you tell us what the error is.

[edit]
I am so betting that it has something to do with you not declaring the three strings loan1, loan2, loan3 before you use them.



Sorry- my compiler says... MortgageCalculator2.java:58: '}' expected
1 error
tool completed with exit code 1
User is offlineProfile CardPM
+Quote Post

GWatt
RE: Java Error
3 Feb, 2008 - 01:52 PM
Post #4

human inside
Group Icon

Joined: 1 Dec, 2005
Posts: 2,360



Thanked: 31 times
Dream Kudos: 500
My Contributions
You need to close each method with a '}' and when you're done you need to close the class with a '}'
You're missing one at the end.
User is online!Profile CardPM
+Quote Post

greenhorn100
RE: Java Error
3 Feb, 2008 - 03:11 PM
Post #5

New D.I.C Head
*

Joined: 24 Jan, 2008
Posts: 7

QUOTE(GWatt @ 3 Feb, 2008 - 02:52 PM) *

You need to close each method with a '}' and when you're done you need to close the class with a '}'
You're missing one at the end.


Okay, thanks...I can see where I need to close the class. However, I do not see where I need to close the methods.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 01:51PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month