Java Using Arguments in a Complex Formula -
i new java, , reading book on now. book not give me answer. using following code:
package loanpayments; public class loanpayments { public static void main(string[] args) { double years = double.parsedouble(args[0]); double p = double.parsedouble(args[1]); double r = double.parsedouble(args[2]); double r = r / 100; double = p*(math.e*math.exp(r*years)); system.out.println(a); } }
i testing code following values:
- years = 3
- p = 2340
- r = 3.1
first have divide r 100 correct value (in case becomes 0.031). new value of 0.031 becomes capitalized r. use formula find a.
i getting incorrect output of ~6980.712, when output should instead ~2568.060.
i thinking put in formula wrong, should this:
pe^r(years)
in case e euler's number (~2.71828)
if advise me on how fix formula, or other mistake, appreciate it, thanks.
not needed multiply e because math.exp() exponential function.
Comments
Post a Comment