Forums: » Register « |  Free Tools |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |
 User Name: Password: Remember me

New Free Tools on Dev Shed!
We're Excited to announce that Dev Shed now has 70 free tools on the site. To learn more, click here!

 Dev Shed Forums Sponsor:
#1
March 24th, 2013, 08:56 AM
 Life_Student
Contributing User

Join Date: Mar 2013
Posts: 41
Time spent in forums: 16 h 8 m 19 sec
Reputation Power: 1
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
March 24th, 2013, 08:57 AM
 mythos_
Registered User

Join Date: Mar 2013
Posts: 25
Time spent in forums: 6 h 59 m 27 sec
Reputation Power: 0
Quote:

help with what? looks like u missed something in ur post...

#3
March 24th, 2013, 09:01 AM
 Life_Student
Contributing User

Join Date: Mar 2013
Posts: 41
Time spent in forums: 16 h 8 m 19 sec
Reputation Power: 1
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
March 24th, 2013, 09:05 AM
 Life_Student
Contributing User

Join Date: Mar 2013
Posts: 41
Time spent in forums: 16 h 8 m 19 sec
Reputation Power: 1
the formula is

pmt = ((p-d)*r/12) / (1-(1+(r/12)^-m)

#5
March 24th, 2013, 09:06 AM
 mythos_
Registered User

Join Date: Mar 2013
Posts: 25
Time spent in forums: 6 h 59 m 27 sec
Reputation 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
March 24th, 2013, 09:31 AM
 Life_Student
Contributing User

Join Date: Mar 2013
Posts: 41
Time spent in forums: 16 h 8 m 19 sec
Reputation Power: 1
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
March 24th, 2013, 09:40 AM
 mythos_
Registered User

Join Date: Mar 2013
Posts: 25
Time spent in forums: 6 h 59 m 27 sec
Reputation 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
March 24th, 2013, 09:41 AM
 Life_Student
Contributing User

Join Date: Mar 2013
Posts: 41
Time spent in forums: 16 h 8 m 19 sec
Reputation Power: 1
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
March 24th, 2013, 09:51 AM
 mythos_
Registered User

Join Date: Mar 2013
Posts: 25
Time spent in forums: 6 h 59 m 27 sec
Reputation Power: 0
Quote:
 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
March 24th, 2013, 10:06 AM
 Life_Student
Contributing User

Join Date: Mar 2013
Posts: 41
Time spent in forums: 16 h 8 m 19 sec
Reputation Power: 1
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
March 24th, 2013, 10:14 AM
 mythos_
Registered User

Join Date: Mar 2013
Posts: 25
Time spent in forums: 6 h 59 m 27 sec
Reputation 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
March 24th, 2013, 10:19 AM
 Life_Student
Contributing User

Join Date: Mar 2013
Posts: 41
Time spent in forums: 16 h 8 m 19 sec
Reputation Power: 1
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
March 24th, 2013, 10:22 AM
 Life_Student
Contributing User

Join Date: Mar 2013
Posts: 41
Time spent in forums: 16 h 8 m 19 sec
Reputation Power: 1
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
March 24th, 2013, 10:26 AM
 mythos_
Registered User

Join Date: Mar 2013
Posts: 25
Time spent in forums: 6 h 59 m 27 sec
Reputation 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
March 24th, 2013, 10:30 AM
 Life_Student
Contributing User

Join Date: Mar 2013
Posts: 41
Time spent in forums: 16 h 8 m 19 sec
Reputation Power: 1
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)))));`

 Viewing: Dev Shed Forums > Programming Languages > Java Help > Help Mortgage payment formula

## Developer Shed Advertisers and Affiliates

 Thread Tools Search this Thread Search this Thread: Advanced Search Display Modes Rate This Thread Linear Mode Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts vB code is On Smilies are On [IMG] code is On HTML code is Off
 View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox Forum Jump Please select one User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home -------------------- Programming Languages    PHP Development        PHP FAQs and Stickies    Perl Programming        Perl FAQs and Stickies    C Programming        C Programming FAQs and Stickies    Java Help        Java FAQs    Python Programming        Python Programming FAQs    Ruby Programming        Ruby Programming FAQs    Game Development        Game Development FAQs Programming Languages - More    ASP Programming        ASP Programming FAQs    .Net Development        .Net Development FAQs    Visual Basic Programming        Visual Basic Programming FAQs    Software Design        Software Design FAQs    ColdFusion Development        ColdFusion Development FAQs    Delphi Programming        Delphi Programming FAQs    Regex Programming        Regex Programming FAQs    XML Programming        XML Programming FAQs    Other Programming Languages        Other Programming Languages FAQs Web Design    HTML Programming        HTML Programming FAQs    JavaScript Development        JavaScript Development FAQs    CSS Help        CSS Help FAQs    Flash Help        Flash Help FAQs    Photoshop Help        Photoshop Help FAQs    Web Design Help        Web Design Help FAQs    Website Critiques        Website Critiques FAQs    Search Engine Optimization        Search Engine Optimization FAQs Mobile Programming    Mobile Programming        Mobile Programming FAQs    iPhone SDK Development        iPhone SDK Development FAQs    Android Development        Android Development FAQs    BlackBerry Development        BlackBerry Development FAQs Web Site Management    Business Help        Business Help FAQs    Development Software        Development Software FAQs    Scripts        Scripts FAQs Databases    Database Management        Database Management FAQs    DB2 Development        DB2 Development FAQs    MySQL Help        MySQL Help FAQs    PostgreSQL Help        PostgreSQL Help FAQs    Firebird SQL Development        Firebird SQL Development FAQs    MS SQL Development        MS SQL Development FAQs    Oracle Development        Oracle Development FAQs    LDAP Programming        LDAP Programming FAQs System Administration    Mail Server Help        Mail Server Help FAQs    Apache Development        Apache Development FAQs    Security and Cryptography        Security and Cryptography FAQs    Antivirus Protection        Antivirus Protection FAQs    DNS        DNS FAQs    IIS        IIS FAQs    Networking Help        Networking Help FAQs    FTP Help        FTP Help FAQs Operating Systems    BSD Help        BSD Help FAQs    Linux Help        Linux Help FAQs    UNIX Help        UNIX Help FAQs    Windows Help        Windows Help FAQs    Mac Help        Mac Help FAQs Web Hosting    Web Hosting        Web Hosting FAQs    Free Web Hosting        Free Web Hosting FAQs    Web Hosting Requests        Web Hosting Requests FAQs    Web Hosting Offers        Web Hosting Offers FAQs Computer Hardware    Computer Hardware    CPUs        CPUs FAQs    Cooling        Cooling FAQs    Embedded Programming        Embedded Programming FAQs    Motherboards        Motherboards FAQs    Multimedia Hardware        Multimedia Hardware FAQs Other    Dev Shed Lounge        Dev Shed Lounge FAQs    Development Articles        Development Articles FAQs    Beginner Programming        Beginner Programming FAQs    Hire A Programmer        Hire A Programmer FAQs    Project Help Wanted        Project Help Wanted FAQs Latest News Updated Hourly    Technology News    Business News    Science News Forum Information    Forum Rules/Guidelines        Forum Rules/Guidelines FAQs    Forum Announcements        Forum Announcements FAQs    Dev Shed Gaming Center        Go to the Dev Shed Battle Arena        Go to the Dev Shed Arcade Games        Go to the Legend of the Green Dragon    Suggestions & Feedback        Suggestions & Feedback FAQs

 Forums: » Register « |  Free Tools |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |