You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
609 B

package com.company.mathe;
public class pqFormelRechner {
public static String berechnePQFormel(double P, double Q){
double eingabe = (P/2) * (P/2) - Q;
if (eingabe >= 0) {
double x1,x2;
x1 = -(P/2) + Math.sqrt(eingabe);
x2 = -(P/2) - Math.sqrt(eingabe);
if (x1==x2){
return "Das Ergebnis ist L={"+x2+"}";
}
else {
return "Die Ergebnisse sind L={"+x1+";"+x2+"}";
}
}
else {
return "Keine Lösung, das Ergebniss ist "+eingabe;
}
}
}