Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Your objective, when given a segment of data is it to: 1. Read and utilize the code given a. All getters have been done for

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed
Your objective, when given a segment of data is it to: 1. Read and utilize the code given a. All \"getters\" have been done for you b. C. Implement setters. i. Pay special attention to all of the setters, that's where the real work begins Don't change x of the prewritten code. 2. Read from a TXT (plain text) le a. Validation of data iS NOT NECESSARY b. But... validating that the file is present and a .txt file is required 3. You will read from the le ONLY once. Each time you read a line, resize the dynamic array declared in the main to t the newest line. a. b. 0. Length will vary by rows in data les Ex: 30 rows of data = 30 seconds = dynamic array length of 30 Ex: 23 rows of data = 23 seconds = dynamic array length of 23 4. Display (code already given) the following results from the earthquake data set a. 99.0? Maximum amplitude Minimum amplitude (usually 0) 5 wave arrival (in seconds) Distance earthquake was recorded from College Station Did the location move (there can be slight movement as the faults slip into a new place) i. Either longitudinal or latitudinal ii. Depth Example When given input files (like below, figure 1) with various numbers of lines, there will be several pieces of data on the same line. Input File (gooddata1.txt) 5 43. 0831 -73. 7846 13.6 4.9 43. 0831 -73.7846 13.6 4.7 43. 0831 -73. 7846 13.6 4.5 43. 0831 -73. 7846 13.6 4.3 43. 0831 -73. 7846 13.6 4. 1 43. 0831 -73. 7846 13.6 2.2 43. 0831 -73. 7846 13.6 [column 1] - Amplitude (valid values can be from 0.0 to 10.0) [column 2] - Latitude location where earthquake happened [column 3] - Longitude location where earthquake happened[column 4] - Depth location where earthquake happened Each row is considered a recorded time of 1 sec. Earthquakes on average last less than 30 seconds, but there have been a few within the last decade in China that have been over a minute. As mentioned above, you will be mining through the data for some results. But that data will be read from the le and dumped into the array shown in the main, with the code given. From that code, you will begin the rest of your result generation. Expected Output (gooddata1.txt) Max amp: 9.5 Min amp: 0.9 Length of Quake: 30 S wave arrival (in seconds): 14 Location of Quake: 73.784600 43.083100 Distance from Quake: 2424km Did quake lat/long move? (0/1): 0 Did quake depth move? (0/1): 1 One of the most important parts of the results you will be asked to nd, is when does the 8 wave arrive. For a general explanation of this, please follow the video linked M (https:llyoutu.be/zFKI1 iPmetY?t=36) until the 1:55 mark. The data les will represent that wave numerically (first column). There are some assumptions that had to be made in order to keep things simple: 1. The P wave will also shrink in intensity until the S wave arrives. 2. There will only be 2 \"peaks\" in amplitude in the data segment given. 3. The rst wave will always be P, then S. 4. The min/max amplitude will be positive (absolute value) In the code notice a few key items: 1. 9391:\" There is a class called QuakeDataSegment that will be used in concert with the dynamic array. The array should be large enough to contain each second (or each row in the le) to further data mine. Since you won't know how big to make the array initially, you will need to resize the array as you add new data. By the end you should not have any unused array elements. The dynamic \"dataSegment\" within main, will be passed to every function in the class EarthQuake. There is only TWO FUNCTIONS of the header that is to be altered (see Update to Pass by Reference) Additional includes are NOT allowed You are not to create any other "helper functions". The local coordinates are already set for College Station. Update to Pass by Reference There is an intentional mistake in the parameter list in TWO of the functions. You will need to change the function signature in the header and the matching signature in the source by adding an &. Required Functions You are required to implement the following functions in EarthQuake.cpp. Q_uakeDataSegment Constructors Notes 0 Implement both QuakeDataSegment constructors 0 Default constructor (you may set all values to 0) o Parameterized constructor o The declarations are given in the header, but you will need to implement them in the source le 0 You should use the preferred method for initialization in constructors resizeArray Notes 0 Resize the input array to an array of length + 1 0 Copy the old data 0 Updates the pointer to the new data array load EarthquakeData Input Parameters o Pointer to a QuakeDataSegment array 0 The lename (as a string) of a le with data in the following format 0 You can assume the data is valid. File Format Each line of the file will be a spaceseparated list of the: Amplitude latitude longitude depth (see above under Example) Return 0 None (void) Other changes 0 Updates the pointer to the array with the new data Throws o std: :invalid_argument o If unable to open the le 0 If the file is not .txt extension Notes Loads data from le into EarthQuakeDataSegment array Uses the resize function to make space for the next data set from the le Uses the EarthQuakeDataSegment data member length to track the segment size Throw invalid_argument for any possible issues that arise in the function setMaxAmplitude Notes 0 Find the maximum amplitude within the data segment 0 Set found maximum amplitude to class data member setMinAmplitude Notes Find the minimum amplitude within the data segment . Set found minimum amplitude to class data member setSWaveIndex Notes . The S wave always comes after the P wave (first line in the file starts the P wave)o The start of the 8 wave can be determined if the current index amplitude is 4x larger than previous index amplitude setEarthquakeLocation Notes 0 Pull latitude and longitude data from data segment index 0 setChangelnLatLong Notes 0 Was there any change in the latitude OR longitude location from the data retrieved. 0 Set class data member to false if latitude OR longitude location did not change setChangelnDepth Notes 0 Was there any change in the depth from the data retrieved. 0 Set class data member to false if depth did not change

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions