Question: The USGS provides FlowSample data in tab - delimited lines of text where each data field is separate by tabs . This is nearly the

The USGS provides FlowSample data in tab-delimited lines of text where each data field is separate by tabs. This is nearly the same situation that we learned about in the previous module with comma separated values, except here tabs are used to separate the fields instead of commas. For this activity we are going add functionality to the FlowSample class so that we can construct a new FlowSample from a single String value containing the required fields in tab-delimited format. Instead of prompting the user for each individual value, we will prompt the user for a single line of text that contains the tab-separated values as shown in the output below:
Please enter the line of tab separated data: USGS 132060002021-12-3014:30 MST 226 P
Program Design
Please copy FlowSample.java from the FlowSampleEntry folder into the FlowSampleParser folder. We will implement additional functionality in this class to allow us to create a new FlowSample object from a String of tab separated values.
Constructor
Add a second constructor to the FlowSample class that takes a single String value as a parameter as shown in the following header signature:
public FlowSample(String line){...}
The mapping of tab separated values (fields) within the line is shown in the image below with field 1 cooresponding to agency, field 2 cooresponding to siteNumber and so on...
The CSVParser example from the previous module is an excellent reference for how to use a Scanner to extract individual fields from a line of String data. In this case, the delimiter value will need to be changed from ',' to '\t'. You will need to reuse the code in the first constructor to create the new Date object using data from the timeZone and timeStamp fields.
For this activity, you may assume that the user provides correctly formatted tsv data. The purpose of this activity is to demonstrate multiple ways that a new object can be instantiated, not on all the ways the end user can frack up data entry. :)
Driver class
Once the FlowSample class has been updated, add code to the main() method in FlowSampleParser.java that uses a Scanner object to prompt the user for a line of tab separated data values, creates a new FlowSample object using the constructor created above, then calls each of the accessor methods and the toString method and displays the results in the console.
Expected Program Output (with sample user input)
---------------------| Data Entry |--------------------- Please enter the line of tab separated data: USGS 132060002021-12-3014:30 MST 226 P ---------------------| Data Confirmation |--------------------- You entered the following: Agency: USGS Site Number: 13206000 Local Timestamp: Thu 30 Dec 202102:30:00 PM MST UTC Timestamp: Thu 30 Dec 202109:30:00 PM UTC Flow Rate: 226.0 Qualification Code: P ---------------------| Sample Summary |--------------------- ### USGS -13206000 ### Timestamp: Thu 30 Dec 202109:30:00 PM UTC Flow Rate: 226.0
Implementation Guide
Expand the folder named FlowSampleParser, copy FlowSample.java from the FlowSampleEntry activity and open FlowSample.java and FlowSampleParser.java
Design a program to satisfy the requirements in the Problem Description and Program Design sections

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!