# Mortgage Monthly Payment Formula

• 04-28-2011, 12:01 AM
EpyonCustom
Mortgage Monthly Payment Formula
Greetings Java Forums,

I have to create a method that calculates the mortgage monthly payment, using the following formula:

Loan Payment Formula

But I don't know how I'm supposed to write this in Java, specifically the power part.

How would I go about writing this formula in Java? Thanks again.
• 04-28-2011, 12:03 AM
sunde887
I didn't follow the link(I don't follow links) but you can use Math.pow, would you mind copy and pasting the formula?
• 04-28-2011, 12:11 AM
EpyonCustom
Here is the formula:

http://www.1728.com/loanfrm2.gif
• 04-28-2011, 12:18 AM
sunde887
What have you tried so far?
• 04-28-2011, 12:18 AM
dlorde
It's probably easiest to break it down into stages so you can check each stage is giving the right result, e.g. (pseudocode)
a = 1 + rate
b = Math.pow(a, months)
c = b - 1
d = rate / c
e = rate + d
f = e * principal

If that's too simple, you can combine steps together, as you see fit.
• 04-28-2011, 12:21 AM
EpyonCustom
Quote:

Originally Posted by sunde887
What have you tried so far?

I basically typed out the formula without the power:

double monthlyInterestPayment=(0.0032 + (0.0032 / ((1 + 0.0032) - 1)) + 1800);

Quote:

Originally Posted by dlorde
It's probably easiest to break it down into stages so you can check each stage is giving the right result, e.g. (pseudocode)
a = 1 + rate
b = Math.pow(a, months)
c = b - 1
d = rate / c
e = rate + d
f = e * principal

If that's too simple, you can combine steps together, as you see fit.

Thanks. I think I'll do something like that. I'll let you guys know if it works.

EDIT: Yep, it works. +rep to both of you guys.

Now I just have to figure out how to do the rest of this assignment!