Question: When we have a large collection of data it is often desirable to be able to generate statistical information about the data in aggregate. In
When we have a large collection of data it is often desirable to be able to generate statistical information about the data in aggregate. In this activing we are going t extend our MonitoringStation class to provide the following statistics over the observation data: Max Flow Rate Min Flow Rate Avg Flow Rate Number of Samples There is obviously a lot more we could do with our collection of FlowSample data, but these should be sufficent for our purposes. :) Program Design Please copy FlowSample.java and MonitoringStation.java from the MonitoringStation folder into the RiverFlowStats folder. This will allow the reuse of these classes. Use the javadoc comments below to implement four additional methods in the MonitoringStation class. Iterate through the ArrayList of FlowSample objects and maintain a reference to the FlowSample object with the highest flow rate value. If a FlowSample with a higher flow rate is found, update the reference to point at the higher object. Once the the entire collection of observations has been processed, return the reference to FlowSample object with the highest flow rate. If a FlowSample is found with the same flow rate as the current highest flow rate, do not update the reference. If the ArrayList of observations is empty, return null @return Reference to FlowSample object containing the highest flow rate value public FlowSample getMaxFlowRate Iterate through the ArrayList of FlowSample objects and maintain a reference to the FlowSample object with the lowest flow rate value. If a FlowSample with a lower flow rate is found, update the reference to point at the lower object. Once the the entire collection of observations has been processed, return the reference to FlowSample object with the lowest flow rate. If a FlowSample is found with the same flow rate as the current lowest flow rate, do not update the reference. If the ArrayList of observations is empty, return null @return Reference to FlowSample object containing the lowest flow rate value public FlowSample getMinFlowRate Iterate through the ArrayList of FlowSample objects to calculate the average flow rate for the set of observations. Return this value as double to the caller If the ArrayList of observations is empty, return @return Average flow rate public double getAvgFlowRate Return the total number of FlowSample observations @return Total number of FlowSample observations for this Monitoringstations public int getNumSamples In the main method of the RiverFlowStats class, use a Scanner to prompt the user to enter a StationID, Description and Filename of text file contain tab delimited sample data. Check if the file exists and is a file and if it does not, display an error message and prompt the user again. Use the user supplied StationID and Description to create a new MonitoringStation object. Then call the loadSampleData method to populated the MonitoringStation with data. Store the return value to a variable and display a message in the console stating that it successfully loaded N samples. Use the getMaxFlowRate and getMinFlowRate methods to get references to FlowSample objects for the respective values. Then call the toString method on each and display the resulting String data in the console. Use the getAvgFlowRate and getNumSamples methods to get double and int values respectively and display them with appropriate label in the console. Use the DecimalFormat class to format the double value to decimal places. The examples below show the expected output for a the years and Expected Program Output with sample user input Station Setup Please enter the station id: Please enter the station description: Boise River at Glenwood Bridge Please enter the filename: glenwood boise tsv Successfully loaded samples Max Flow Sample ### USGS ### Timestamp: Wed Apr : : PM UTC Flow Rate: Min Flow Sample
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
