Code:
Java:
import javax.swing.JOptionPane;
public class Loesungsanzahl {
public static void main(String[] args) {
String eingabe;
String eingabe1;
String eingabe2;
double a;
double b;
double c;
double D;
eingabe = JOptionPane.showInputDialog("Geben sie a an: "); // Eingabe von a
a = Double.parseDouble(eingabe);
eingabe1 = JOptionPane.showInputDialog("Geben sie b an: "); // Eingabe von b
b = Double.parseDouble(eingabe1);
eingabe2 = JOptionPane.showInputDialog("Geben sie c an: "); // Eingabe von c
c = Double.parseDouble(eingabe2);
D = b * b - 4 * a * c; // Berechnung des Diskriminanten D
if (D == 0) {
JOptionPane.showMessageDialog(null, "Die quadratische Gleichung hat eine Loesung!");
} else {
if (D > 0) {
JOptionPane.showMessageDialog(null, "Die quadratische Gleichung hat zwei Loesungen"); }
} else {
if (D < 0) {
JOptionPane.showMessageDialog(null, "Die quadratische Gleichung hat keine Loesung"); }
}
}
}