March 24th, 2013, 07:56 AM

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
please help
March 24th, 2013, 07:57 AM

Originally Posted by Life_Student
please help
help with what? looks like u missed something in ur post...
March 24th, 2013, 08:01 AM

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))));
}
}
March 24th, 2013, 08:05 AM

the formula is
pmt = ((pd)*r/12) / (1(1+(r/12)^m)
March 24th, 2013, 08:06 AM

it would help if put in codetags. 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?
March 24th, 2013, 08:31 AM

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 = ((pd)*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.
March 24th, 2013, 08:40 AM

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.
March 24th, 2013, 08:41 AM

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
March 24th, 2013, 08:51 AM

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.
March 24th, 2013, 09:06 AM

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?
March 24th, 2013, 09:14 AM

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...
March 24th, 2013, 09:19 AM

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
March 24th, 2013, 09:22 AM

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?
March 24th, 2013, 09:26 AM

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)
March 24th, 2013, 09:30 AM

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