From cdda2694c39ad6b235c6e9c878baf54583097e69 Mon Sep 17 00:00:00 2001 From: Robin Date: Fri, 31 Jan 2025 15:29:53 +0100 Subject: [PATCH] =?UTF-8?q?Mitternachtsformelrechner=20erg=C3=A4nzt=20Mitt?= =?UTF-8?q?ernachtsformelrechner=20klappt=20nich?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Eingabe.java | 7 +---- Mitternachtsformelrechner.java | 49 ++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 6 deletions(-) create mode 100644 Mitternachtsformelrechner.java diff --git a/Eingabe.java b/Eingabe.java index 0f5e95e..c7f24db 100644 --- a/Eingabe.java +++ b/Eingabe.java @@ -1,10 +1,5 @@ -/** - * Beschreiben Sie hier die Klasse Eingabe. - * - * @author (Ihr Name) - * @version (eine Versionsnummer oder ein Datum) - */ + import java.util.Scanner; public class Eingabe { diff --git a/Mitternachtsformelrechner.java b/Mitternachtsformelrechner.java new file mode 100644 index 0000000..12e24fd --- /dev/null +++ b/Mitternachtsformelrechner.java @@ -0,0 +1,49 @@ +import java.util.Scanner; + +public class Mitternachtsformelrechner +{ +public static void Mitternachtsformelrechner() + { +Scanner sc = new Scanner(System.in); +System.out.println("Erste Zahl eingebne:"); +double a = sc.nextInt(); + + System.out.println("Zweite Zahl eingebne:"); +double b = sc.nextInt(); + + System.out.println("Dritte Zahl eingebne:"); +double c = sc.nextInt(); + + double root; +root = Math.sqrt((b * b) - (4 * a * c)); + +double bottom; + bottom = (2 * a); + +double result1; +result1 = (-b + root) / bottom; +System.out.print("x1=:"); +System.out.println(result1); + + +double result2; +result2 = (-b - root) / bottom; +System.out.print("x2=:"); +System.out.println(result2); +if( root < 0) { + System.out.print("Ich rechne nicht gern Mitternachtsformel weils cool is sondern weil ich gerne Mitternachtsformel rechne basta abgesehn davon rechne ich keine Mitternachtsformel..."); +} +else{ + if( root == 0) { + System.out.print("x1=:"); +System.out.println(result1); + +System.out.print("x2=:"); +System.out.println(result2); + } +} +} +} + + +