I'm just starting out with programming and need to do an assignment for class where I approximate pi using the first 8 terms in the sequence. I need to do this by creating a variable 'nextTerm' with initial value 1, variable 'denominator' with initial value 1, and variable 'series' with initial value 0. I get the first term when I run it, but then it only shows a line of zeros. I honestly have no clue what I'm doing.
public class ApproxPI
{
public static void main(String[] args)
{
int nextTerm = 1;
int denominator = 1;
int series = 0;
for (int denominator = 1; denominator <= 8; denominator++) {
series = ((-1 * ((-1 * nextTerm) / denominator)) * 4);
System.out.println("Pi is approximately" + series);
}
}
}