### Thread: Help Mortgage payment formula

Page 1 of 3 123 Last
1. No Profile Picture
Contributing User
Devshed Newbie (0 - 499 posts)

Join Date
Mar 2013
Posts
43
Rep Power
6

#### Help Mortgage payment formula

I dont know how to enter this formula properly its the monthly mortgage payment formula:
this is what have so far, but I dont know how to enter the rest of the formula
2. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Mar 2013
Posts
25
Rep Power
0
Originally Posted by Life_Student
help with what? looks like u missed something in ur post...
3. No Profile Picture
Contributing User
Devshed Newbie (0 - 499 posts)

Join Date
Mar 2013
Posts
43
Rep Power
6
yes this would probably help

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 monthlyPayment= ( ((housePrice - downPayment) * (annualInterestRate/12)) /((1-(1+(annualInterestRate/12)^-numberofPayments))));

}
}
4. No Profile Picture
Contributing User
Devshed Newbie (0 - 499 posts)

Join Date
Mar 2013
Posts
43
Rep Power
6
the formula is

pmt = ((p-d)*r/12) / (1-(1+(r/12)^-m)
5. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Mar 2013
Posts
25
Rep Power
0
it would help if put in code-tags. and again: whats the problem? You try to implement a formula, which formula? Whats the problem with the code u posted? wrong output? (if yes which?) any errormessages?

edit: ok formula added, whats p,d,r and m in the formula?
6. No Profile Picture
Contributing User
Devshed Newbie (0 - 499 posts)

Join Date
Mar 2013
Posts
43
Rep Power
6
alright ill try to do this proper:

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 monthlyPayment= ( ((housePrice - downPayment) * (annualInterestRate/12)) /((1-(1+(annualInterestRate/12)^-numberofPayments))));

System.out.println( (monthlyPayment+ " is the larger of the two numbers.");

}
}```
the formula: pmt = ((p-d)*r/12) / (1-(1+(r/12)^-m)

In which PMT is the monthly payment, P is the listed price of the house, D is the
down payment, r is the annual interest rate and m is the number of payments.

i hope this is clearer let me know please.
7. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Mar 2013
Posts
25
Rep Power
0
much easier to read, thanks. but still, what is ur problem?

i guess ur code is not compiling (although u didnt say that).

and i suggest u look into "Math.pow(a,b)" instead of the " a^b " in the code.
8. No Profile Picture
Contributing User
Devshed Newbie (0 - 499 posts)

Join Date
Mar 2013
Posts
43
Rep Power
6
my problem is i know about math.pow but how do i implement it in this code specifically with a negative exponent?? the very last part of the formula i cant enter correctly
9. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Mar 2013
Posts
25
Rep Power
0
Originally Posted by Life_Student
my problem is i know about math.pow but how do i implement it in this code specifically with a negative exponent??
if you have a^b in the formula, ur write Math.pow(a,b) in the code.

You have (r/12)^-m in the formula, so you write Math.pow(r/12,-m) in the code. should work.
10. No Profile Picture
Contributing User
Devshed Newbie (0 - 499 posts)

Join Date
Mar 2013
Posts
43
Rep Power
6
ok so i tried this:

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

but when i run it iget negative numbers also the math seems wrong can someone please check this equation?
11. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Mar 2013
Posts
25
Rep Power
0
Are you sure the formula is correct? Where did u get it from?

Specially the (1-(1+(r/12)^-m)) part seems strange. Cause that results just to -(r/12)^-m...
12. No Profile Picture
Contributing User
Devshed Newbie (0 - 499 posts)

Join Date
Mar 2013
Posts
43
Rep Power
6
well on my specs for this the formula is written like this:

PMT = (P -D)* r/12
___________
(1-(1+r/12)^-m)

where
PMT is the monthly payment, P is the listed price of the house, D is the
down payment, r is the annual interest rate and m is the number of payments.

i thought i wrote it write but never entered as complex formula before so not sure if i entered it correctly
13. No Profile Picture
Contributing User
Devshed Newbie (0 - 499 posts)

Join Date
Mar 2013
Posts
43
Rep Power
6
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 monthlyPayment= ( ((housePrice - downPayment) * (annualInterestRate/12)) /((1-(1+Math.pow(annualInterestRate/12, -numberofPayments)))));

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);

}
}```
this is my current code the math doesnt compute correctly could someone please check?
14. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Mar 2013
Posts
25
Rep Power
0
You got the formula wrong.

u wrote (1-(1+(r/12)^-m)) but the formula u are stating now says (1- (1+(r/12))^-m). (one parenthisis wrong)
15. No Profile Picture
Contributing User
Devshed Newbie (0 - 499 posts)

Join Date
Mar 2013
Posts
43
Rep Power
6
ok im confused if i put the parentheses wrong where should it go in this line
Code:
`double monthlyPayment= ( ((housePrice - downPayment) * (annualInterestRate/12)) /((1-(1+Math.pow(annualInterestRate/12, -numberofPayments)))));`
Page 1 of 3 123 Last