abcFormel Rechner. (nicht fertig)

master
Domen 2025-01-31 15:29:58 +01:00
parent a47837e2ca
commit de04b108d6
1 changed files with 68 additions and 0 deletions

68
abcRechner.java Normal file
View File

@ -0,0 +1,68 @@
import java.util.Scanner;
public class abcRechner
{
public static void abcrechenr()
{
//screen display
Scanner sc = new Scanner(System.in);
System.out.println("Input first number");
double a = sc.nextInt();
System.out.println("Input second number");
double b = sc.nextInt();
System.out.println("Input thinrd number");
double c = sc.nextInt();
//program start
double root;
root = Math.sqrt((b * b) - (4 * a * c));
double bottom;
bottom = 2 * a;
double result1;
result1 = (-b + root) / bottom;
double result2;
result2 = (-b - root) / bottom;
//outputs
if( root < 0) {
System.out.print("no answer possible");
}
else{
if( root == 0) {
System.out.print("The answer is: ");
}
else{
System.out.print("first answer is: ");
System.out.println(result1);
System.out.print("second answer is: ");
System.out.println(result2);
}
}
}
}