The loop would terminate if the two sums were subtracted, and produced a difference of 0.0000009 or less (7 significant figure accuracy). Restrict the total time your program uses to 10 minutes. One with n+1 iterations, the other with n iterations. 3.12 Write another Java program that repeatedly uses ASRCAT to calculate Pi for i 3,4,5. Perhaps having a for loop inside a for loop would work better. Is this a good approach, or is it horribly inefficient? How might I improve it? ("The number of iterations needed to reach " + "seven-significant digit accuracy is: " + counter) ("The library constant value of pi is: " + Math.PI) ("My computed value of pi is: " + sum * DENOMINATOR_CANCEL) Home c/c++/java/python practice question and ans Program to Calculate the surface area and volume of a Cylinder SOURAV KUMAR PATRA JProblem statement:- Program to Calculate the surface area and volume of a Cylinder. If (delta < SMALLEST_DELTA) // If delta reaches 7-sig accuracy Here is the code I came up with to do that: public class ComputePIįinal double SMALLEST_DELTA = 0.0000004535899 įor (int j = 1 j < LARGE_NUMBER j += 2) // Computes number close to piĭouble firstFrac = (1.0 / (j * 2.0 - 1.0)) ĭouble secondFrac = (1.0 / (j * 2.0 + 1.0)) įor (int i = 1 (!closeEnough) i += 2) //"My computed value of pi"ĭouble firstNum = (1.0 / (i * 2.0 - 1.0)) ĭouble secondNum = (1.0 / (i * 2.0 + 1.0)) ĭelta = sumOne * DENOMINATOR_CANCEL - sum * DENOMINATOR_CANCEL I need to calculate pi to 7 significant figures in Java- without using Math.PI.