# Monthly mortgage payment calculator

Show 40 post(s) from this thread on one page
Page 2 of 2 First 12
• March 24th, 2013, 10:53 AM
iamgonge
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
• March 24th, 2013, 10:58 AM
Norm
Re: Monthly mortgage payment calculator
You need to continue breaking the compound expressions down into single expressions and printing their values.
• March 24th, 2013, 10:59 AM
iamgonge
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?
• March 24th, 2013, 11:01 AM
Norm
Re: Monthly mortgage payment calculator
Quote:

what else needs to be done
You need to find where the error is in that compound expression.
• March 24th, 2013, 11:05 AM
iamgonge
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!!!!!!!!!!
• March 24th, 2013, 11:10 AM
Norm
Re: Monthly mortgage payment calculator
Quote:

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.
• March 24th, 2013, 11:13 AM
iamgonge
Re: Monthly mortgage payment calculator
i dont know how to break this line down any further
Code :

```  double tempBottom = ((1-(1+(Math.pow(annualInterestRate/12, -numberofPayments)))));```
on paper sure in java no clue
• March 24th, 2013, 11:15 AM
Norm
Re: Monthly mortgage payment calculator
Start on the inside and work out: aIR/12, Math.pow()
• March 24th, 2013, 11:20 AM
iamgonge
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
• March 24th, 2013, 11:22 AM
Norm
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.
• March 24th, 2013, 11:39 AM
iamgonge
Re: Monthly mortgage payment calculator
i apologize just frustrated I think i figured it
Code :

`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 ---

Code :

```    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
• March 24th, 2013, 11:46 AM
Norm
Re: Monthly mortgage payment calculator
• March 24th, 2013, 11:47 AM
StephenCoyle
Re: Monthly mortgage payment calculator
Quote:

Originally Posted by iamgonge
i dont know how to break this line down any further
Code :

```  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
• March 24th, 2013, 11:59 AM
iamgonge
Re: Monthly mortgage payment calculator
thank you
Show 40 post(s) from this thread on one page
Page 2 of 2 First 12