Java Reference
In-Depth Information
18 */
19 public String getDescription()
20 {
21 String r;
22 if (richter >= 8.0)
23 r = ÐMost structures fallÑ;
24 else if (richter >= 7.0)
25 r = ÐMany buildings destroyedÑ;
26 else if (richter >= 6.0)
27 r = ÐMany buildings considerably
damaged, some collapseÑ;
28 else if (richter >= 4.5)
29 r = ÐDamage to poorly constructed
buildingsÑ;
30 else if (richter >= 3.5)
31 r = ÐFelt by many people, no
destructionÑ;
32 else if (richter >= 0)
33 r = ÐGenerally not felt by peopleÑ;
34 else
35 r = ÐNegative numbers are not
validÑ;
36 return r;
37 }
38
39 private double richter;
40 }
ch05/quake/EarthquakeRunner.java
1 import java.util .Scanner;
2
3 /**
4This program prints a description of an earthquake of a given
magnitude.
5 */
6 public class EarthquakeRunner
7 {
8 public static void main(String[] args)
9 {
10 Scanner in = new Scanner(System.in);
11
12 System.out.print(ÐEnter a magnitude
on the Richter scale: Ñ);
Search WWH ::




Custom Search