Close
Duke shfaqur rezultatin -9 deri 0 prej 4
  1. #1
    i/e regjistruar Maska e agonny
    Anėtarėsuar
    02-08-2008
    Postime
    251

    Ndihm ne JAVA Plz Help :$

    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

    Kodi:
    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.

  2. #2
    i/e regjistruar Maska e agonny
    Anėtarėsuar
    02-08-2008
    Postime
    251
    helllllooo!?

  3. #3
    i/e regjistruar Maska e Gepardi
    Anėtarėsuar
    30-10-2002
    Vendndodhja
    Tiranė
    Postime
    169
    Kodi:
    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));          
      }
    }

  4. #4
    i/e regjistruar Maska e agonny
    Anėtarėsuar
    02-08-2008
    Postime
    251
    flm Gepard kshtu e kem zgjidh na


    Kodi:
    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);
    	
      }
      
    }

Regullat e Postimit

  • Ju nuk mund tė hapni tema tė reja.
  • Ju nuk mund tė postoni nė tema.
  • Ju nuk mund tė bashkėngjitni skedarė.
  • Ju nuk mund tė ndryshoni postimet tuaja.
  •