Assignment 7import java.util.Scanner; public class Assign7_Wood { public static void main (String[] args) { Scanner myScanner = new Scanner(System.in); double sum double PI for ( i=2; i <= 1000 ; i = i +2 ){ sum = sum - something + something PI = 4.0 * ( 1.0 + sum ) } System.out.println("When i is 800 PI is: ") System.out.println("When i is 900 PI is: ") System.out.println("When i is 1000 PI is: ") } }
Mathematicians define the constant PI to be
PI = 4 *( 1 - 1/(2*2-1) + 1/(2*2+1) - 1/(2*4-1) + 1/(2*4+1) - 1/(2*6-1) + 1/(2*6+1)- . . . .format . . . . . - 1/(2*i-1) + 1/(2*i+1) )
Note that i starts at 2 and is incremented by 2. The higher the i, the more precise PI will be. Also note that the higher the value of i, the smaller the value of PI.
Write a program that displays the value of PI for i = 800, 900 and 1000. Output should be something like this :
when i is 800 PI is xxxx
when i is 900 PI is xxxx
when i is 1000 PI is xxxx
I expect your program to look something like this :
double sum double PI for ( i=2; i <= 1000 ; i = i +2 ) { sum = sum - something + something PI = 4.0 * ( 1.0 + sum ) }
Once you have this working, enhance the program, add another section. The next section of the program should determine the value of i needed to achieve a value of PI that is equal to or slightly smaller than 3.1419. The program should output the following message :
value of i to give PI equal or smaller than 3.1419 is xxxxxx
Name of program should be Assign7_{your last name} .
Programs should have comments and output pasted at the bottom in the same style and manner of previous assignments.
Above is what i have so far and am not doint so well. I have no idea what he expects in the something part in the variable sum