We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0fced0c commit 2b0c848Copy full SHA for 2b0c848
1 file changed
Exercise.java
@@ -1,6 +1,24 @@
1
+import java.util.Scanner;
2
+
3
public class Exercise {
4
5
public static void main(String[] args) {
- // implement exercise here
6
+ @SuppressWarnings("resource")
7
+ Scanner sc = new Scanner(System.in);
8
+ double x1 = 0, x2 = 0;
9
10
+ System.out.print("Gib bitte einen Wert fuer a ein: ");
11
+ double a = sc.nextDouble();
12
+ System.out.print("Gib bitte einen Wert fuer b ein: ");
13
+ double b = sc.nextDouble();
14
+ System.out.print("Gib bitte einen Wert fuer c ein: ");
15
+ double c = sc.nextDouble();
16
17
+ x1 = ((-b + Math.sqrt((Math.pow(b, 2) - (4 * a * c)))) / (2 * a));
18
+ x2 = ((-b - Math.sqrt((Math.pow(b, 2) - (4 * a * c)))) / (2 * a));
19
20
+ System.out.printf("x1 = %.1f%n", x1);
21
+ System.out.printf("x2 = %.1f%n", x2);
22
23
}
24
0 commit comments