Question: hi can someone help me with this code... class Earthquake { double rate; String reading; Earthquake(double r) { rate = r; } public String toString()

hi can someone help me with this code...

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());

}

}

  • Write what you think will appear on the screen when the program is executed.[1 mark]

______________________________________________________________________________________

____________________________________________________________________________________

  • Type the program, compile and run it.Record the output.Was your answer different from the machine's answer? (Y N ). If Y, explain why your answer was incorrect, and fix the problem.[3 marks]

______________________________________________________________________________________

______________________________________________________________________________________

______________________________________________________________________________________

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mathematics Questions!