1 Preparation A Zip archive containing the files for the assignment is provided in Minerva. When you unzip it, you should see three files of earthquake data, along with four .java files. One of these, QuakeException.java, is complete and ready for you to use; the other three files containing empty Java classes. There are 'To Do' comments inside the classes that summarise the code that you need to write, and detailed step-by-step instructions are provided below. Before you begin programming, take some time to study the sample data. You can use a spreadsheet application to do this. Each row in the dataset represents a single earthquake. The different columns represent various parameters measured for an earthquake. You don't need to know what most of these are, although further details can be found at the USGS Earthquake Hazards Program website if you are interested. The only columns relevant to this assignment are: latitude, longitude, depth and magnitude. Note that filenames consist of two parts: a severity level (often expressed in terms of earthquake magnitude) and a time period. The two parts are separated by the underscore character. Thus, 2.5_day.csv contains details of earthquakes of magnitude 2.5 or greater , recorded over a single day; 4.5_week.csv records earthquakes of magnitude 4.5 or greater, over a one-week period; and significant_month.csv records 'significant' earthquakes recorded during a one-month period. 2 Quake Class This class encapsulates the details of a single earthquake. 1. Edit Quake.java in a text editor. Add to the class fields that represent the latitude, longitude, depth and magnitude of an earthquake. 2. Create a constructor for Quake that takes a single String parameter. This string represents all of the data provided by the USGS for a single earthquake, with each value separated from the others by commas. To see real examples of what this string looks like , open one of the data files in a text editor (not in a spreadsheet), and examine any of the lines after the first. Note: you can use a method of the String class to help you implement this. Your constructor should perform some basic validation, checking that latitude is within the allowed range of −90.0 ◦ to 90.0 ◦ , and that longitude is within the allowed range of −180.0 ◦ to 180.0 ◦ . You should throw an instance of QuakeException, containing an appropriate error message, if latitude or longitude are invalid. 3. Write simple 'getter' methods for each of the fields. These methods should simply return the values ​​of the fields. 4. Write a toString method for Quake. This should generate and return a string representation of the Quake object. The string should contain magnitude, depth, latitude and longitude, in that order, formatted like this example: M5.0, 12.6 km, (35.4975°, 141.0217°) Note: the 'degrees' symbol can be generated with the Unicode escape sequence \u00b0. As you complete each step of implementing this class, remove the corresponding 'To Do' comment and check that your code compiles. Once you've written the constructor and getter methods, you can test them by writing a small program that creates a Quake object from a string. You can use one of the lines from the given data files as the string.   Quake.java

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

1 Preparation

A Zip archive containing the files for the assignment is provided in Minerva. When you unzip it, you should see three files of earthquake data, along with four .java files. One of these, QuakeException.java, is complete and ready for you to use; the other three files containing empty Java classes.

There are 'To Do' comments inside the classes that summarise the code that you need to write, and detailed step-by-step instructions are provided below.

Before you begin programming, take some time to study the sample data. You can use a spreadsheet application to do this. Each row in the dataset represents a single earthquake. The different columns represent various parameters measured for an earthquake. You don't need to know what most of these are, although further details can be found at the USGS Earthquake Hazards Program website if you are interested. The only columns relevant to this assignment are: latitude, longitude, depth and magnitude.

Note that filenames consist of two parts: a severity level (often expressed in terms of earthquake magnitude) and a time period. The two parts are separated by the underscore character. Thus, 2.5_day.csv contains details of earthquakes of magnitude 2.5 or greater , recorded over a single day; 4.5_week.csv records earthquakes of magnitude 4.5 or greater, over a one-week period; and significant_month.csv records 'significant' earthquakes recorded during a one-month period.

2 Quake Class

This class encapsulates the details of a single earthquake.

1. Edit Quake.java in a text editor. Add to the class fields that represent the latitude, longitude, depth and magnitude of an earthquake.

2. Create a constructor for Quake that takes a single String parameter. This string represents all of the data provided by the USGS for a single earthquake, with each value separated from the others by commas. To see real examples of what this string looks like , open one of the data files in a text editor (not in a spreadsheet), and examine any of the lines after the first. Note: you can use a method of the String class to help you implement this. Your constructor should perform some basic validation, checking that latitude is within the allowed range of −90.0 ◦ to 90.0 ◦ , and that longitude is within the allowed range of −180.0 ◦ to 180.0 ◦ . You should throw an instance of QuakeException, containing an appropriate error message, if latitude or longitude are invalid.

3. Write simple 'getter' methods for each of the fields. These methods should simply return the values ​​of the fields.

4. Write a toString method for Quake. This should generate and return a string representation of the Quake object. The string should contain magnitude, depth, latitude and longitude, in that order, formatted like this example: M5.0, 12.6 km, (35.4975°, 141.0217°) Note: the 'degrees' symbol can be generated with the Unicode escape sequence \u00b0. As you complete each step of implementing this class, remove the corresponding 'To Do' comment and check that your code compiles. Once you've written the constructor and getter methods, you can test them by writing a small program that creates a Quake object from a string. You can use one of the lines from the given data files as the string.

 

Quake.java

 

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Study of Characters
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY