Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Linear Algebra A Modern Introduction

Authors: David Poole

4th edition

1285463242, 978-1285982830, 1285982835, 978-1285463247

More Books

Students also viewed these Mathematics questions