# Shkenca > Informatikë dhe Internet > Arti i programimit >  Ndihm ne JAVA              Plz Help :$

## agonny

a mundet dikush mem ndihmu per me bo ket detyre !
tek e fundit veq do ndihma plz !
edhe me ma sqaru ma shqiptarski bre vlla qka po kerkohet  :i ngrysur: 



```
Write a method that computes the value of PI by using this equation:
PI = 4 * ( 1 - 1/3 + 1/5 - 1/7 + ... )
The parameter to the method is the maximum value of the denominator
, n, used in the fractions, 1/n, in the series. Insert the method in a test
 program and try it on various parameters and compare your 
results with the value of the Java constant Math.PI.
```

----------


## agonny

*helllllooo!?*

----------


## Gepardi

```
public class PiTest {
  
  public static double pi (int n) {
    double pi = 0;
    int j = 1;
    for (double i=1;i<=n;i=i+2) {
      pi = pi - Math.pow (-1,j) * (1/i);
      j++;
    }
    return 4*pi;
  }
  
  public static void main(String args[]) {
    double n1;

    for (int n=100;n<500;n=n+5) {
       n1 = pi(n);
       System.out.println("Test value for n = " +  Double.toString(n) + " is: "
          +  Double.toString(n1));
    }
    
    System.out.println("Value of Math.pi() is: " +  Double.toString(Math.PI));          
  }
}
```

----------


## agonny

flm Gepard kshtu e kem zgjidh na  :buzeqeshje: 




```
import javax.swing.*;
public class Detyra
{ public static void main(String[] args)
  { 
   double s = new Double(JOptionPane.showInputDialog("Jepeni nje vlere")).doubleValue();
    Detyra.pI(s);
  }
  public static void pI(double n)
  {
  
	double pi=0.0;
	boolean m = true;
	for(double i = 1 ; i <= n;i=i+2)
     {  if (m)
	     { pi = pi + 1/i; m = false;  }
	     else
	     { pi = pi - 1/i; m = true; }
     }
	 System.out.println("sipas codit: "+4.0 * pi);
	 System.out.println("math.pi : "+Math.PI);
	
  }
  
}
```

----------

