I AM DESPERATELY NEEDING HELP ON THIS PROGRAM, IT IS DUE TODAY BY MIDNIGHT 12/28.... IF ANY ONE COULD HELP ME I WOULD BE VERY THANKFUL!...... THANK YOU
Due November 28th, 2002.
Goal: More practice with control structures and math computations.
Description: You will be writing a program to to find approximate value of
the transcendental number 'e'. This number is expressed as an infinite sum
of the type:
1/1! + 1/2! + 1/3! + 1/4! + .... + 1/n!+...and so on. This is an infinite sum.
Your program finds the sum of first few finitely many terms. The number of
terms in your sum is to be obtained from the user. Your program should ask
the use for the precision with which the user wants the value of 'e' to be
computed. Your proigram should print the sum of those many terms! For your
information, the value of e lies in between 2 and 3, and is taken to be equal
to 2.7831, which is correct upto 4 decimal places.
Here's a sample run of the program:
enter the desired precision for e: 126
value of e to using precision 12 is 2.71828
enter the desired precision for e: 2
value of e to using precision 2 is 2.5
enter the desired precision for e: 3
value of e to using precision 3 is 2.66667
enter the desired precision for e: 6
value of e to using precision 6 is 2.71806
enter the desired precision for e: 8
value of e to using precision 8 is 2.71828
Your program should use at least 3 methods,
Your program should not use the for statement,
Your program should not use math library functions from java.math or java.lang
post what code you have so far and ask specific questions concerning what you can't do or dont understand, then someone may help you.
not trying to be mean but other people have lives too and they can't write a program for you every week.
[code] /* dont forget code tags! */ [/code]
Come visit the Café!
I just need help with a method
Hi i finished my program . but i need to incorporate a third method,, because the program needs 2 other methods other than Main... i was thinking i could just make a method to print out the value?? but i cannot figure out how..... if anyone could help,, please reply... thank you!
public class CalculatingE
public static void main (String args) throws IOException
int n, x = 0;
double answer = 1, i;
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter the desired value for E >");
n = Integer.parseInt(input.readLine());
i = n;
while (x < n)
answer = answer + (1 / CalculatingE.computefact(i));
i = i - 1;
x = x + 1;
public static double computefact (double a)
if ((a == 1) || (a == 0))
fact = 1.0;
int i = 0; fact = 1;
while (i < a)
fact = fact * (a-i);
i = i + 1;
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL