Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a program that will allow scientific queries to be performed on ( actual ) earthquake data. The ( very large ) file quakes.zip is
Write a program that will allow scientific queries to be performed on actual earthquake data. The very
large file quakes.zip is provided and includes all earthquakes worldwide with magnitudes on Richter
Scale from through Summer The file format is:
datetimelatitudelongitudemagnitudelocation
with data delimited by a pipe character. A seismologist is requesting that an API application program
interface be created to allow basic queries to be performed on the dataset with minimum keystrokes.
Initially, read the entire contents of the data file to an arraybased data structure. You can choose parallel
arrays or an array of objects. You will then be be performing searches on the arrays Please avoid use of
specialized Java "container" classes such as ArrayLists, HashMaps, etc.
Your API will allow the user to key in a string into the program interface
RminLat,maxLat,minLon,maxLon List all quakes in dataset by region with northsouth boundary
between minLat and maxLat, and eastwest boundary between
minLon and maxLon.
DminDate,maxDate List all quakes in dataset by date with the calendar date of the
quake from minDate and maxDate. Include quakes from the
minimum date through and including the maximum date.
MminMag List all quakes in dataset with magnitude minMag or greater.
Queries must be validated prior to processing. First, validate that the format matches one of the patterns
above. This implies that each must begin with a character R D or M only. Next, be sure that the number of
commadelimited tokens match the expected pattern. Finally, be sure the data contained in each token are
valid. Earthquake magnitudes must be or greater. Latitudes must be to degrees. The
minimum latitude would be the southern boundary. Longitudes can only be to The minimum
longitude would be the western boundary. To validate the calendar dates, you have permission to use
algorithms demonstrated in class. Along with two valid dates, be sure the first date is less than or equal to
the second date.
For any queries that do not match this format, provide an error message and allow the user to start again.
Some valid sample queries could be:
R
M
D
For your interface,use simple console input via the Scanner class Similarly, output can be directed to the
Java console to restrict your earthquake data system to a commandline application. A simple query will
likely generate a long list of earthquake events. Pull all matching quakes from you data stored in the
arraybased data structure and list all that satisfy the query. Once all information has been displayed, be
sure to return to the menu to give the user the the option to perform another query or quit.
Formatting of the "raw" quake data is expected. For example, if the following data line from the file matches
the query:
T::Zkm S of Galesburg; Michigan
reformat it for your output to look like:
MAY Z Mag: km S of Galesburg; Michigan
Be sure to round the geographical coordinates to two decimal places. Also, reformat the event datetime
from the coded format to a "friendlier" format. For example:
Change: T::Z to: MAR Z
where each month will be abbreviated to three characters and the universal Z time is rounded to the
nearest minute with all colons removed. Note also that the day of the month will always be two digits and
the time will always be four digits including any leading zeros Make sure the minute is correctly rounded
up or down to the nearest minute.
Design your solution with appropriate modularity in mind. Either a procedural approach or an object
oriented are acceptable. This is whatI have so far import java.io;
import java.util.Scanner;
public class quakeFinder
public static final int REGIONTOKENS ;
public static final int DATETOKENS ;
public static final int MAGTOKENS ;
public static final String FILENAME "quakes.txt;
public static final int MAXLENGTH ;
public static void mainString args
int fileEntries ; Number of lines of data in the file.
String rawQuakeData new StringMAXLENGTH;
Holds data for magnitude in secondChar and lat and long min and max for every char.
double secondChar thirdChar fourthChar fifthChar ;
I needed to put these up here because they would only conditionally exist if I didn't.
Java didn't like that, so now they're here.
String minDate maxDate ;
Booleans to check if the input was valid so we can output the data.
boolean choseR false;
boolean choseD false;
boolean choseM false;
Arrays to hold split up data.
String dateTimeData new StringMAXLENGTH;
double latitudeDa
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started