Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

1. Re: Monthly mortgage payment calculator

ok when i run this program it asks questions i enter the following
house price = 1000
down payment = 50
interest rate = .05
number of payments 30
top equation: double tempTop = ((housePrice - downPayment) * (annualInterestRate/12));
bottom equation: double tempBottom = ((1-(1+(Math.pow(annualInterestRate/12, -numberofPayments)))));
double monthlyPayment = (tempTop / tempBottom);

the end results are top equation = 3.9583333333333335
end result for bottom equation = -2.548808761537613E71 negative number
mortgage payment = top/bottom = -1.5530130753887556E-71 negative number

2. Re: Monthly mortgage payment calculator

You need to continue breaking the compound expressions down into single expressions and printing their values.

3. Re: Monthly mortgage payment calculator

what will that accomplish i dont get what your trying to do i showed you the formula and i showed you how i broke it down what else needs to be done?

4. Re: Monthly mortgage payment calculator

what else needs to be done
You need to find where the error is in that compound expression.

5. Re: Monthly mortgage payment calculator

its in bottom expression but i dont know how to fix it thats problem i can break it down all day long but something is wrong please help me!!!!!!!!!!

6. Re: Monthly mortgage payment calculator

i can break it down all day long but something is wrong
There aren't an infinite number of subexpressions so I expect you can do it in a few minutes.

You need to verify that all the subexpressions are working correctly.

7. Re: Monthly mortgage payment calculator

i dont know how to break this line down any further
```
double tempBottom = ((1-(1+(Math.pow(annualInterestRate/12, -numberofPayments)))));```
on paper sure in java no clue

8. Re: Monthly mortgage payment calculator

Start on the inside and work out: aIR/12, Math.pow()

9. Re: Monthly mortgage payment calculator

forget it im struggling for hours now and all your doing is asking me more questions. thanks for nothing its much appreciated

10. Re: Monthly mortgage payment calculator

Sorry, if you didn't find someone to do your work for you. I thought you were interested in learning programming techniques. Among those techniques is debugging. That's what I've been suggesting that you do with your code so YOU could find what the problem with YOUR code is.

Good luck.

11. Re: Monthly mortgage payment calculator

i apologize just frustrated I think i figured it
`double tempBottom = ((1-(Math.pow(1+(annualInterestRate/12), -numberofPayments))));`
my 1+ was in the wrong spot, Norm you were right when i broke it completely down i saw it thanks

--- Update ---

```

import java.util.Scanner;

public class Project1 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);

System.out.println("Enter the price of the house: ");
double housePrice = input.nextDouble();
System.out.println("Enter the down payment: ");
double downPayment = input.nextDouble();
System.out.println("Enter the annual interest rate: ");
double annualInterestRate = input.nextDouble();
System.out.println("Enter the number of payments: ");
double numberofPayments = input.nextDouble();

double tempTop = ((housePrice - downPayment) * (annualInterestRate/12));
double tempBottom = ((1-(Math.pow(1+(annualInterestRate/12), -numberofPayments))));
double monthlyPayment = (tempTop / tempBottom);

System.out.println( "The price of the house is: " + housePrice);
System.out.println( "Your down payment is : " + downPayment);
System.out.println( "Your annual interest rate is :" + annualInterestRate);
System.out.println( "Your number of payments are: " + numberofPayments);
System.out.println( "Your monthly payment is: " + monthlyPayment);
System.out.println( "");
System.out.println( "Top of equation equals: " + tempTop);

System.out.println( "Bottom of equation equals: " + tempBottom);

}
}```

i think im on track please check

13. Re: Monthly mortgage payment calculator

Originally Posted by iamgonge
i dont know how to break this line down any further
```
double tempBottom = ((1-(1+(Math.pow(annualInterestRate/12, -numberofPayments)))));```
on paper sure in java no clue
Norm is trying to help you to help yourself. You can't learn something if people just give you the answer. Especially in programming. Now look at this line off code I quoted and look at how the math.pow method works. Do you see a problem.

Norm is correct when he tells you to "continue breaking the compound expressions down into single expressions". This helps you to find if your calculations are wrong and were they are going wrong. For example :
3*(35+(50/5)) - to break this down
3*(35+10)
3*45
ANS = 135

14. Re: Monthly mortgage payment calculator

thank you

Page 2 of 2 First 12