Skip to content

Commit 2b0c848

Browse files
committed
implement solution
1 parent 0fced0c commit 2b0c848

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

Exercise.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
1+
import java.util.Scanner;
2+
13
public class Exercise {
24

35
public static void main(String[] args) {
4-
// 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+
523
}
624
}

0 commit comments

Comments
 (0)