help w/ PI Math java program

im currently in entry level java class and need help with a code..here are my instructions

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 = 100, 200, 300, . . ,1000. Output should be something like this :

when i is 100 PI is xxxx

when i is 200 PI is xxxx

etc . .

when i is 900 PI is xxxx

when i is 1000 PI is xxxx

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

and here is my code, i underlined the part where im getting an errors

should i put each value of PI in an if statement?? im kinda stuck right now thanks

Code:

`public class ConstantPI {`

public static void main(String[] args)

{

[U]int i = 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000;[/U]

double pi4 = 1.0;

for(int j = 2; j <= i; j += 2)

pi4 = pi4 - 1/(2*(double)j - 1) + 1/(2*(double)j + 1);

double pi = 4.0*pi4;

System.out.println("When i is " + i + " PI is " + pi);

}

}

btw cross posted thanks

http://www.javaprogrammingforums.com...html#post26927

There's a mismatch in '{' and '}' to print the statement "value of i to give PI .."

public static void main(String[] args)

{

for (int i = 100; i <= 3300; i += 100) {

double pi4 = 1.0;

for(int j = 2; j <= i; j += 2)

pi4 = pi4 - 1/(2*(double)j - 1) + 1/(2*(double)j + 1);

double pi = 4.0*pi4;

System.out.println("When i is " + i + " PI is " + pi);

}

} < -- Remove this

//next section

//determine value of i

int i = 0;

double pi = 100;

{ < -- Remove this

do

{

i ++;

double pi4 = 1.0;

for(int j = 2; j <= i; j += 2)

pi4 = pi4 - 1/(2*(double)j - 1) + 1/(2*(double)j + 1);

pi = 4.0*pi4;

} while (pi > 3.1419);

System.out.println("value of i to give PI equal or smaller than 3.1419 is " + i);

} < -- Remove this

}