class Earthquake
{
double rate;
String reading;
Earthquake(double r)
{
rate = r;
}
public String toString()
{
if ( rate > 6.0)
reading = "Most structures will fall";
if ( rate > 4.5)
reading = "Many buildings will fall";
if ( rate > 3.0)
reading = "Many buildings will be slightly damaged";
if ( rate > 1.5)
reading = "Many people will feel the quake";
if ( rate > 0.5)
reading = "Most people will not feel the quake";
return reading;
}
}
class TestQuake
{
public static void main(String arg[])
{
Earthquake e = new Earthquake(8.0);
System.out.println(e.toString(
Get Free Quote!
450 Experts Online