Results 1 to 2 of 2
 10282011, 07:46 AM #1Member
 Join Date
 Oct 2011
 Posts
 5
 Rep Power
 0
Code to determine how many elements of a givine infinite series are required to
find the value of pi, accurate to 5 decimal places?
Sorry the title got cut off. If not the code I'd appreciate a step by step explanation of how to do this problem.
Here it is:
Write a java project (Application) with just a driver class. This class should have a default constructor and a main method which calls it.
This project should determine how many elements of the infinite series shown below are required to find the value of pi, accurate to 5 decimal places.
pi / 4 = 1  1 / 3 + 1 / 5  1 / 7 + 1 / 9  1 / 11 + ...
You must use the following constant
private static final double PI = 3.14159;
and your program must use a do loop.
Your output should look like this:
Value of pi = 3.14159
Number of elements of the series = 130657
The value of pi is not the value of the constant, instead it is the value of the series rounded to 5 places.
Thanks in advance for your time.
 10282011, 08:15 AM #2
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 14,423
 Blog Entries
 7
 Rep Power
 27
Re: Code to determine how many elements of a givine infinite series are required to
First write a bit of code that creates the series 1/11/3+1/51/7 ... and work from there (the numerator flips between 1 and 1 while the deniminator takes the values 1, 3, 5, 7 ...).
kind regards,
JosBuild a wall around Donald Trump; I'll pay for it.
Similar Threads

Help required in executing the following code
By vivekdarshan in forum Advanced JavaReplies: 6Last Post: 01242011, 12:24 PM 
Help required in executing the following code
By vivekdarshan in forum Advanced JavaReplies: 0Last Post: 01232011, 09:34 AM 
How to determine the size of object (facilityExceptionData) in code below
By neetigya in forum Advanced JavaReplies: 6Last Post: 10112010, 01:59 PM 
Getting ExceptionInInitializer exception when i am trying to code a time series chart
By neeraj.singh in forum AWT / SwingReplies: 2Last Post: 02172009, 03:20 PM 
code required
By baba in forum JavaServer Pages (JSP) and JSTLReplies: 6Last Post: 10062008, 03:43 PM
Bookmarks