title: Calculating Pi Java Program
body: <p>I'm taking my first Java programming class and this is my first class project. I'm so confused about how to approach it. Any help or correction will be appreciated. </p>
  
  <p>You can approximate the value of the constant PI by using the following series:</p>
  
  <pre><code>PI = 4 ( 1 - 1/3 + 1/5 - 1/7 + 1/9 - 1/11 + ... + ( (-1)^(i+1) )/ (2i - 1) )
  </code></pre>
  
  <p>Prompt the user for the value of i (in other words, how many terms in this series to use) to 
  calculate PI. For example, if the user enters 10000, sum the ﬁrst 10,000 elements of the series and then display the result.</p>
  
  <p>In addition to displaying the ﬁnal result (your ﬁnal approximation of PI), I want you to display along the way your intermediate calculates at every power of 10. So 10, 100, 1000, 10000 and so on, display to the screen the approximation of PI at that number of summed elements.</p>
  
  <p>This is what i did so far ..</p>
  
  <pre><code>import java.util.Scanner;
          public class CalculatePI {
  
              public static void main(String[] args) {
                  // Create a Scanner object
                  Scanner input = new Scanner (System.in);
  
                  // Prompt the user to enter input
                  System.out.println("Enter number of terms");
                  double i = input.nextDouble(); // value of i user entered
                      double sum = 0;
                  for(i=0; i&lt;10000; i++){
                             if(i%2 == 0) // if the remainder of `i/2` is 0
                             sum += -1 / ( 2 * i - 1);
                          else
                             sum += 1 / (2 * i - 1);
      }
  
                          System.out.println(sum);
  
  
      }
  }
  </code></pre>