Write what you think will appear on the screen when the program is executed

computer science


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


  • 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]

Related Questions in computer science category

The ready solutions purchased from Library are already used solutions. Please do not submit them directly as it may lead to plagiarism. Once paid, the solution file download link will be sent to your provided email. Please either use them for learning purpose or re-write them in your own language. In case if you haven't get the email, do let us know via chat support.