-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKokHesaplamaOrneği.java
30 lines (24 loc) · 990 Bytes
/
KokHesaplamaOrneği.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import java.util.Scanner;
public class KokHesaplamaOrneği {
public static void main(String args[]) {
Scanner input = new Scanner(System.in);
System.out.println("Lütfen sırasıyla a, b ve c'yi giriniz.");
double a = input.nextDouble();
double b = input.nextDouble();
double c = input.nextDouble();
double delta = b * b - (4 * (a * c));
double x1, x2;
if (delta > 0) {
x1 = (-b - Math.sqrt(delta)) / 2 * a;
x2 = (-b + Math.sqrt(delta)) / 2 * a;
System.out.println("Girdiğiniz denklemin 2 farklı kökü vardır. Birinci kök: " + x1 + " İkinci kök: " + x2);
}
else if (delta < 0) {
System.out.println("Denklemin reel kökü yoktur.");
}
else {
double xeşit = -b / 2 * a;
System.out.println("Girdiğiniz denklemin iki eşit kökü vardır. x1=x2: " + xeşit);
}
}
}