diff --git a/.devcontainer.json b/.devcontainer.json new file mode 100644 index 0000000..bfbeb0d --- /dev/null +++ b/.devcontainer.json @@ -0,0 +1,3 @@ +{ + "image": "mcr.microsoft.com/devcontainers/java:21" +} \ No newline at end of file diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..add4f4e --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "vscjava.vscode-java-pack" + ] +} \ No newline at end of file diff --git a/Exercise.java b/Exercise.java index 3c092f9..ff43644 100644 --- a/Exercise.java +++ b/Exercise.java @@ -1,6 +1,23 @@ +import java.util.Scanner; + public class Exercise { public static void main(String[] args) { - // implement exercise here + @SuppressWarnings("resource") + Scanner sc = new Scanner(System.in); + double x1 = 0, x2 = 0; + + System.out.print("Gib bitte einen Wert fuer a ein: "); + double a = sc.nextDouble(); + System.out.print("Gib bitte einen Wert fuer b ein: "); + double b = sc.nextDouble(); + System.out.print("Gib bitte einen Wert fuer c ein: "); + double c = sc.nextDouble(); + + x1 = ((-b + Math.sqrt((Math.pow(b, 2) - (4 * a * c)))) / (2 * a)); + x2 = ((-b - Math.sqrt((Math.pow(b, 2) - (4 * a * c)))) / (2 * a)); + + System.out.printf("x1 = %.1f%n", x1); + System.out.printf("x2 = %.1f%n", x2); } }