please , help me .. how can i solve this attachment by Java program?
@zepdrix @Nnesha
class PiEst{ public static void main(String args[]){ float calc = m(201); System.out.println( calc + "\n"); } public static float m (int i){ float addPI = 0; for (int j = 1; j<=i; j++){ addPI +=(Math.pow((-1),(j+1))) /((2*j) -1); } return 4*addPI; } }
table class PiEst{ public static void main(String args[]){ float calc =0; for(int i = 0; i<10; i++){ calc = m(i); System.out.println( i+"\t\t"+calc + "\n"); } } public static float m (int i){ float addPI = 0; for (int j = 1; j<=i; j++){ addPI +=(Math.pow((-1),(j+1))) /((2*j) -1); } return 4*addPI; } }
this will be calculate the PI of numbers less than 10 .. and we need it calculate the PI for ( 1,101,201,301,401,501,601) , i have not find the equation which do it
@SolomonZelman @ParthKohli
make a few modification to the code. change the number. instead of incrementing the loop by 1, you can have the loop increment by 100. like this for(int i = 1; i<=601; i+=100){ //do some stuff }
Join our real-time social learning platform and learn together with your friends!