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

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




Mortage Claculator

 
Reply to this topicStart new topic

Mortage Claculator, Errors in my code

johnnyknoxville
15 Sep, 2008 - 12:51 PM
Post #1

New D.I.C Head
*

Joined: 15 Sep, 2008
Posts: 3

I am new to programming. I have written this program. I keep on getting "symbols not found. This is a mortage calculator that allows the end user to enter a fixed interest rate, # of years, amount borrowed, and estimated escrow
import java.util.*;



public class MortagePayments2
{

public static void main(String[] args)
{

String AmountofMortageLoan;
String InterestRate;
String LengthofLoan;
String EstimatedEscrowAmount;
double MORTAGELOAN;
double INTERSETRATE;
double LENGTHOFLOAN;
double ESTIMATEDESCROWAMOUNT;
double MONTHLYPAYMENTS;
double RATE;
double PAYMENTS;
double LENGTH;
double MIDDLE;

Scanner in;

in = new Scanner(System.in);
System.out.print("Amount of Mortage Loan: ");
AmountofMortageLoan = in.nextLine();
System.out.print("Enter Interest Rate: ");
InterestRate = in.nextLine();
System.out.print("Length of Loan: ");
LengthofLoan = in.nextLine;
System.out.print("Estimated Escrow Amount: ");
EstimatedEscrowAmount = in.nextLine();
// Calculate and display Monthly Payments
MORTAGELOAN = Double.parseDouble(AmountofMortageLoan);
LENGTHOFLOAN = Double.parseDouble(LengthofLoan);
INTERESTRATE = Double.parseDouble(InterestRate);
ESTIMATEDESCROWAMOUNT = Double.parseDouble(EstimatedEscrowAmount);
LENGTH = LENGTHOFLOAN * 12;
RATE = INTERESTRATE / 1200;
MIDDLE = ((1 + RATE)^LENGTH) -1;
PAYMENTS = RATE + (RATE/MIDDLE)* LENGTH;
System.out.println("Your Monthly Mortage Payments is:" + PAYMENTS);

}
}

This post has been edited by johnnyknoxville: 15 Sep, 2008 - 01:02 PM
User is offlineProfile CardPM
+Quote Post

nick2price
RE: Mortage Claculator
15 Sep, 2008 - 01:26 PM
Post #2

D.I.C Regular
***

Joined: 23 Nov, 2007
Posts: 338



Thanked: 12 times
My Contributions
Right, compiled it and got some errors.
First one
Cannot find symbal variable nextLine;
Your calling up a java method here so your code should be
CODE
LengthofLoan = in.nextLine();

You forgot the ().

Second error is cannot find symbal variable INTERESTRATE

Thats because you have made a spelling mistake when you declared it.

Last error is oporator ^ cannot be applied to double,double

I havnt actally used ^ before. What are you trying to do here? Because the error is telling you that you cannot perform this mathematical operation on two doubles.
User is offlineProfile CardPM
+Quote Post

johnnyknoxville
RE: Mortage Claculator
15 Sep, 2008 - 02:16 PM
Post #3

New D.I.C Head
*

Joined: 15 Sep, 2008
Posts: 3

QUOTE(nick2price @ 15 Sep, 2008 - 02:26 PM) *

Right, compiled it and got some errors.
First one
Cannot find symbal variable nextLine;
Your calling up a java method here so your code should be
CODE
LengthofLoan = in.nextLine();

You forgot the ().

Second error is cannot find symbal variable INTERESTRATE

Thats because you have made a spelling mistake when you declared it.

Last error is oporator ^ cannot be applied to double,double

I havnt actally used ^ before. What are you trying to do here? Because the error is telling you that you cannot perform this mathematical operation on two doubles.


I went through it again and did find some errors. I have fixed them and compiled it. It works, but the forumla doesnot come out correctly

The formula that i am trying to work in is

monthly payment = [interest rate + (interest rate) / ((1 - interest rate ^ months) - 1] * amount of mortage loan + estimated escrow amount

CODE

import java.util.*;



public class MortagePayments2
{

    public static void main(String[] args)
        {
    
    String AmountofMortageLoan;            
    String InterestRate;                
    String LengthofLoan;                
    String EstimatedEscrowAmount;                                    
    double MORTAGELOAN;                
    double INTERESTRATE;                
    double LENGTHOFLOAN;    
    double ESTIMATEDESCROWAMOUNT;            
    double MONTHLYPAYMENTS;                
    double RATE;
    double PAYMENTS;
    double LENGTH;
    long MIDDLE;
    
        Scanner in;                    

    in = new Scanner(System.in);
    System.out.print("Amount of Mortage Loan: ");    
    AmountofMortageLoan = in.nextLine();        
    System.out.print("Enter Interest Rate: ");    
    InterestRate = in.nextLine();            
    System.out.print("Length of Loan: ");        
    LengthofLoan = in.nextLine();        
    System.out.print("Estimated Escrow Amount: ");    
    EstimatedEscrowAmount = in.nextLine();                
    // Calculate and display Monthly Payments
    MORTAGELOAN = Double.parseDouble(AmountofMortageLoan);
    LENGTHOFLOAN = Double.parseDouble(LengthofLoan);
    INTERESTRATE = Double.parseDouble(InterestRate);
    ESTIMATEDESCROWAMOUNT = Double.parseDouble(EstimatedEscrowAmount);
    LENGTH = LENGTHOFLOAN * 12;
    RATE = INTERESTRATE / 1200;
    MIDDLE = (long)(Math.pow(1 + RATE)^LENGTH))-1;
      PAYMENTS = (RATE + (RATE/MIDDLE)* MORTAGELOAN) + ESTIMATEDESCROWAMOUNT;
      System.out.println("Your Monthly Mortage Payments is:" + PAYMENTS);


    }
}


Edited... please use the [ code] tags

This post has been edited by pbl: 15 Sep, 2008 - 03:47 PM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 04:59AM

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