# Thread: beginner grade 11-need help with a math code involving returning values from a method

1. Member
Join Date
Dec 2008
Location
North America
Posts
29
Rep Power
0

## beginner grade 11-need help with a math code involving returning values from a method

My following code is to calculate the monthly payment of someones mortgage. I was given the formula:
payment = loan * (rate/100/12) / ( 1 - ( 1 / ( 1 + (rate/100/12) )) ^ (years * 12 ))

How can I substitute the '^' with Math.pow in order to get this equation to work in my code.

2. Java Code:
```    public static double pow(double a, double b) {
return StrictMath.pow(a, b); // default impl. delegates to StrictMath
}```
There are special casing issues for various situations, this should get you unstuck...

3. Member
Join Date
Dec 2008
Location
North America
Posts
29
Rep Power
0
Im not really sure how to do it still. Its my first year programming and Math.pow is suppose to replace the '^' somehow without nothing to technical.

4. you have to sit there and pencil and paper your way through it...

double years = ?....
double twelve = new Double(12.0000);

( rate divided by 100 divided by 12 )

divided by .... start with the innermost round braces and work your way out, keep careful detail on exactly when each round brace closes, it is programmed by carefully working that one pair at a time:

one plus (rate/100/12) then one is divided by that number then.....

tedious, error-prone, yes.

do homework, no.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•