Results 1 to 5 of 5
Thread: Need Help With Equation in Java
 02082013, 03:32 AM #1Member
 Join Date
 Feb 2013
 Posts
 3
 Rep Power
 0
Need Help With Equation in Java
I just started Java and this is probably a dumb question. I am trying to put the following equation into Java:
In Java I typed the following (this is just a test program, my actual one has commenting/prompts):
final double FACTOR = 1/30;
double b = 0.0;
double n = 0.0;
double p = 0.0;
double dailyInterest = 0.0;
double apr = 0.0;
apr = kb.nextDouble();
b = kb.nextDouble();
p = kb.nextDouble();
dailyInterest = apr/365;
n = FACTOR*((Math.log(1+(b/p)*(1(Math.pow(1+dailyInterest,30)))/Math.log(1+dailyInterest))));
I've tried to break it apart a few different ways and as separate variables to clean it up, but the answer I get is always "NaN" for my n value (the values I am trying to use are 13.65 for apr, 2013 for b, and 25 for p; test values provided by the professor).
Any ideas on why this would be occurring?
 02082013, 03:59 AM #2Member
 Join Date
 Feb 2012
 Posts
 59
 Rep Power
 0
Re: Need Help With Equation in Java
check the value of Factor, I didn't have time to compile and test it out, but if what you wrote is exactly what you had, you may have a data type issue.
so put this somewhere:
System.out.println(FACTOR);
edit I imagine you know what i am pointing out since all of your other values are properly initialized.Last edited by lenois; 02082013 at 04:01 AM.
 02122013, 02:50 AM #3Member
 Join Date
 Feb 2013
 Posts
 3
 Rep Power
 0
 02122013, 07:44 AM #4
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 14,322
 Blog Entries
 7
 Rep Power
 25
Re: Need Help With Equation in Java
If 'apr' is 'annual percentage' then i= (apr/365)/100;
kind regards,
JosThe only person who got everything done by Friday was Robinson Crusoe.
 02122013, 05:04 PM #5Member
 Join Date
 Feb 2013
 Posts
 3
 Rep Power
 0
Similar Threads

Write a java program to display a gui of quadratic equation
By bestlita in forum New To JavaReplies: 4Last Post: 07082011, 06:35 AM 
Math equation in Java Applet
By calnastic in forum New To JavaReplies: 10Last Post: 06232011, 07:36 AM 
converting an algebraic equation to Java
By fsuarjun03 in forum New To JavaReplies: 2Last Post: 03092010, 08:58 PM 
Help with an equation in java
By coco in forum New To JavaReplies: 1Last Post: 07312007, 07:47 AM 
Help with quadratic equation in java
By paul in forum New To JavaReplies: 1Last Post: 07252007, 08:23 PM
Bookmarks