Wednesday, April 25, 2012

Discriminant tənliyin həll metodu (burda əsasən if else yapılandırmasını göstərməyə çalışdım)


 public void discriminant (int a,int b, int c)

    {
           double d = (b*b)-(4*a*c);

           if (d>0)
           {
               System.out.println("Tenliyin iki helli var");
               double x1 = ((-b)-Math.sqrt(d))/(2*a);
               double x2 = ((-b)+Math.sqrt(d))/(2*a);

               System.out.println("x1 = "+ x1);
                System.out.println("x2 = "+ x2);
           }
           else if (d==0)
           {
            System.out.println("Tenliyin bir helli var");
           int x =(-b)/(2*a);
                    System.out.println("x1 = x2 = "+ x);
           }
           else
           {
                System.out.println("Tenliyin helli yoxdur");
           }
    }

No comments:

Post a Comment