Question: Create a program called LeibnizPiCalculation.java. Copy the following code to your file: Import java.util. * ; public class LeibnizPiCalculation { public static void main (

Create a program called LeibnizPiCalculation.java. Copy the following code to your file:
Import java.util.*;
public class LeibnizPiCalculation{
public static void main(String[] args){
Scanner input = new Scanner(System.in);
int n = input.nextInt();
System.out.println("N \t\t Pi");
System.out.println("------------------------");
for(int i =0; i <= n; i +=100){
System.out.println(i+"\t\t"+getLeibniz(i));
}
//Create the getNumerator() method below
//Create the getDenominator() method below
//Create the getLeibniz() method below
}
Expected Output
N: 1000
N Pi
-------------------
04.0
1003.1514934010709914
2003.1465677471829556
3003.1449149035588526
4003.144086415298761
5003.143588659585789
6003.143256545948974
7003.1430191863875865
8003.142841092554028
9003.1427025311614294
10003.1425916543395442

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!