Results 1 to 4 of 4
- 12-10-2008, 12:40 AM #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.
- 12-10-2008, 01:50 AM #2Java Code:
public static double pow(double a, double b) { return StrictMath.pow(a, b); // default impl. delegates to StrictMath }
Introduction to Programming Using Java.
Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor
- 12-10-2008, 02:00 AM #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.
- 12-10-2008, 02:38 AM #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.Introduction to Programming Using Java.
Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor
Similar Threads
-
[SOLVED] Beginner, need help with Returning Values from Methods
By bobmasta5 in forum New To JavaReplies: 11Last Post: 12-08-2008, 01:29 AM -
Need help. Method won't returning proper value..
By zlwilly in forum New To JavaReplies: 2Last Post: 12-02-2008, 10:44 PM -
Simple program involving military time
By busdude in forum New To JavaReplies: 4Last Post: 10-08-2008, 07:03 PM -
[SOLVED] Beginner needs help on Loop,Math-syntax on Graphics
By obdi in forum New To JavaReplies: 13Last Post: 07-06-2008, 10:11 AM -
How to add interceptor to persistent ejb entity to add check before returning values
By umen in forum Enterprise JavaBeans (EJB)Replies: 0Last Post: 12-01-2007, 12:55 AM
Bookmarks