forked from sPredictorX1708/Ultimate-Java-Resources
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuadraticEquation.java
More file actions
30 lines (24 loc) · 901 Bytes
/
QuadraticEquation.java
File metadata and controls
30 lines (24 loc) · 901 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//this program evaluates how much solutions a quadratic equation has
//the quadratic equation should have the following structure:
//ax^2+bx+c=0
import javax.swing.JOptionPane;
public class QuadraticEquation{
public static void main(String[] args){
double a;
double b;
double c;
double D;
String eingabe;
eingabe = JOptionPane.showInputDialog("Insert the value for a!");
a = Double.parseDouble(eingabe);
eingabe = JOptionPane.showInputDialog("Insert the value for b!");
b = Double.parseDouble(eingabe);
eingabe = JOptionPane.showInputDialog("Insert the value for c!");
c = Double.parseDouble(eingabe);
D = b * b - 4 * a *c;
if (D<0){ JOptionPane.showMessageDialog(null, "There is no solution!");}
else { if (D>0){ JOptionPane.showMessageDialog(null, "There are two solutions!");}
else { JOptionPane.showMessageDialog(null, "There is one solution!"); }
}
}
}