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

Re: Monthly mortgage payment calculator

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

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?

Re: Monthly mortgage payment calculator

Quote:

what else needs to be done

You need to find where the error is in that compound expression.

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

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.

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

Re: Monthly mortgage payment calculator

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

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

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.

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

Re: Monthly mortgage payment calculator

Glad you are making progress.

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

Re: Monthly mortgage payment calculator