-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEarthquake.java
32 lines (31 loc) · 1.15 KB
/
Earthquake.java
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
31
32
import javax.swing.JOptionPane;
public class Earthquake {
/**
* @param args
* {@code Create Earthquake class}
*/
public Earthquake() {
String earthq = JOptionPane.showInputDialog(null, "Please Enter the intensity\n(1 to 10) example: 7.2",
"Earthquake Intensity", JOptionPane.INFORMATION_MESSAGE);
try {
double eq = Double.parseDouble(earthq);
if(eq < 4.99) {
JOptionPane.showMessageDialog(null, "Little or No Damage");
} else if(eq <= 5.49) {
JOptionPane.showMessageDialog(null, "Some Damage");
} else if(eq <= 6.49) {
JOptionPane.showMessageDialog(null, "Serious Damage");
} else if(eq <= 7.49){
JOptionPane.showMessageDialog(null, "It's a Disaster");
} else if(eq <= 7.99){
JOptionPane.showMessageDialog(null, "Such a Catastrophe");
} else {
JOptionPane.showMessageDialog(null, "Such a Catastrophe");
}
}
catch(NumberFormatException nFE) {
JOptionPane.showMessageDialog(null, "You've entered a non Numeric data!",
"You've entered a non Numeric data!", JOptionPane.ERROR_MESSAGE);
}
}
}