Question: SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTS ARE TO BE WRITTEN IN JAVA. Assume that the classes listed in the Java Quick Reference have
SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTS ARE TO BE WRITTEN IN JAVA.
Assume that the classes listed in the Java Quick Reference have been imported where appropriate.
Unless otherwise noted in the question, assume that parameters in method calls are not null and that
methods are called only when their preconditions are satisfied.
In writing solutions for each question, you may use any of the accessible methods that are listed in
classes defined in that question. Writing significant amounts of code that can be replaced by a call to one
of these methods will not receive full credit.
This question involves the analysis of weather data. The following WeatherData class has an instance
variable, temperatures, which contains the daily high temperatures recorded on consecutive days at a
particular location. The class also contains methods used to analyze that data. You will write two methods of the
weatherData class.
Write the cleanData method, which modifies the temperatures instance variable by removing all
values that are less than the lower parameter and all values that are greater than the upper parameter. The
order of the remaining values in temperatures must be maintained.
For example, consider a WeatherData object for which temperatures contains the following.
The three shaded values shown would be removed by the method call cleanData
The following shows the contents of temperatures after the three shaded values are removed as a result of
the method call cleanData
Complete method cleanData.
Cleans the data by removing from temperatures all values that are less
lower and all values that are greater than upper, as described in part
a
public void cleanData double lower, double upper
Write the longestHeatWave method, which returns the length of the longest heat wave found in the
temperatures instance variable. A heat wave is a sequence of two or more consecutive days with a daily high
temperature greater than the parameter threshold. The temperatures instance variable is guaranteed to
contain at least one heat wave based on the threshold parameter.
For example, consider the following contents of temperatures.
In the following sample contents of temperatures, all heat waves based on the threshold temperature
of are shaded. The method call longestHeatWave would return which is the length
of the longest heat wave.
In the following sample contents of temperatures, all heat waves based on the threshold temperature
of are shaded. The method call longestheatWave would return which is the length of
the longest heat wave.
Complete method longestHeatWave.
Returns the length of the longest heat wave found in temperatures, as
described in
part b
threcondition: There is at least one heat wave in temperatures based on
threshold.
public int longestHeat.Wave double threshold
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
