Answered step by step
Verified Expert Solution
Question
1 Approved Answer
You will write the class WeatherData to process 1 0 0 years of weather data from a single weather station. It should contain the following
You will write the class WeatherData to process years of weather data from a single weather
station. It should contain the following constructor:
public WeatherDataScanner s
This should load the data provided by the Scanner into your WeatherData class. The data should be
loaded one line of text at a time using the Scanners nextLine method. The first line of text should be
discarded as it is a header. Each line of text, stored in a String, should be split using the split
method. This will create an array of Strings. The relevant Strings are index which indicates the date for
the data on this line, index which will indicate if the day contains multiple days of precipitation or will
be blank if it is just a single day of data index which indicates a multiple day precipitation total or
will be blank if it is a single day of precipitation index which indicates the single day precipitation
total or will be blank if the day contains multiple days of precipitation index which indicates the
days snowfall total, index which indicates the days high temperature and may be blank if this was
not recorded and index which indicates the days low temperature and may be blank if this was not
recorded All other indexes may be ignored.
Every index in the split array that is not blank will be surrounded by double quote characters. The
substring method may help you remove them.
You may assume that each row has a valid date in the form YYYYMMDD and that the dates are in
chronological order, but there may be missing dates. Temperatures are always whole numbers but
precipitation and snowfall may contain decimal points. The Integer.parseInt and
Double.parseDouble methods may help you convert the corresponding String to numeric data.
The constructor will set up data structures to support the methods below. The use of collections will
help the methods run quickly. The constructor must run in under minute or you may receive no
credit for your submission. Each method will be called many times for testing. For each of your
methods, each call must execute in under second or no credit will be awarded for that method.
There will be a penalty or points for a given method if it is too slow which will be tested by
performing many method calls and there will be a point bonus for the whole assignment if none of
your methods are slow.
The class should have the following methods, shown with their corresponding documentation and point
values. The provided starter code will have empty implementations.
Determine whether the given temperature was ever seen as a high temperature
in the data provided to the constructor. points
HINT: This is a membership question. What data structure have we seen that
can help us answer this question?
@param degrees Temperature same units as data file
@return true if high temp, false otherwise
public boolean highTempint degrees
Page of
Determine whether the given temperature was ever seen as a low temperature in
the data provided to the constructor. points
@param degrees Temperature same units as data file
@return true if low temp, false otherwise
public boolean lowTempint degrees
Determine the total amount of snowfall recorded in the given year.
points
HINT: What data structure would allow us to correspond an amount of snowfall
with a year? How much snowfall is recorded in a year not found in the file?
@param year
@return
public double totalSnowfallForYearint year
Determine the average mean total precipitation recorded for the given
month. Be sure to include multiday precipitation amounts. Assume that all
of the precipitation occurs on the date of the multidate range never
divide it across months. points
@param month
@return
public double averagePrecipitationForMonthint month
Return the most common most often observed high temperature seen in the
given month. If there are two or more temperatures that are both seen the
most number of times, return the lowest high temperature. points
@param month Month
@return highest most common high temperature seen in that month
public int lowestMostCommonHighForMonthint month
For the given low temperature, find the highest high temperature seen with
that low. points
@param degrees Low temperature
@return Highest high ever seen for that low temperature
public int highestHighForLowint degrees
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