Java – diskriminant;

Şubat 28, 2020 0 Yazar: alikperislam

package algoritma1;

import java.util.Scanner;

public class delta {

public static void main(String[] args) {
    int a,b,c;
    float delta,x1,x2;
    Scanner scan=new Scanner(System.in);
    System.out.println("a : ");
    a= scan.nextInt();
    System.out.println("b : ");
    b=scan.nextInt();
    System.out.println("c : ");
    c=scan.nextInt();
    float d;
    d=(float) ((b*b)-(4*a*c));
    System.out.println("delta" + d);
    if(d>0){

        System.out.println("2 kök vardır.");
        x1= (float) (-b + Math.sqrt(d) );
        x2= (float) (-b - Math.sqrt(d) );
        System.out.println("kökler : " + x1 + "--" + x2);   
    }
    else if(d==0){
        x1= -b/(2*a);
        System.out.println("çakışık kök : " + x1);



    }
    else {
        //küçükse 0'dan;
        System.out.println("kök yoktur.");


    }



}

}