import java.util.ArrayList; /** * 2023 FRQ 3 * * implementation by Chris Thiel, OFMCap */ public class WeatherData { private ArrayList temperatures; /** * part (a) * * Cleans the data by removing from temperatures all values that are less than * lower and all values that are greater than upper as described in part (a) */ public void cleanData(double lower, double upper) { // Your code here } /** * part (b) * * Returns the length of the longest heat wave found in temperatures as described in part (b) * * Precondition: There is at least one heat wave in temperatures based on threshold. */ public int longestHeatWave(double threshold) { //your code here return -11; } public WeatherData(double[] temps) { temperatures = new ArrayList(); for(double t:temps) temperatures.add(t); } public String toString() { String result =""; for(Double t:temperatures) result += " ("+t+")"; return result; } public static void main(String[] args) { System.out.println("This tests your answer to 2023 FRQ 3"); double[] temps1 = {99.1, 142.0, 85.0, 85.1, 84.6, 94.3, 124.9, 98.0, 101.0, 102.5}; double[] temps1a = {99.1, 85.0, 85.1, 94.3, 98.0, 101.0, 102.5}; double[] temps2 = {100.5, 98.5, 102.0, 103.9, 87.5, 105.2, 90.3, 94.8, 109.1, 102.1, 107.4, 93.2}; WeatherData partA = new WeatherData(temps1); WeatherData partAAnswer = new WeatherData(temps1a); WeatherData partB = new WeatherData(temps2); System.out.println( "Part (a)\nBefore cleanData(85.0, 120.0):\n"+partA ); partA.cleanData(85.0, 120.0); System.out.println( "afterward:\n"+partA ); System.out.println( "should be \n"+partAAnswer ); System.out.println( "\n\nPart (b) example temperatures:\n"+ partB ); System.out.print( "\nlongestHeatWave(100.5)returns: "); System.out.println( partB.longestHeatWave(100.5) + "(should be 3)"); System.out.print( "\nlongestHeatWave(95.2)returns: "); System.out.println( partB.longestHeatWave(95.2) + "(should be 4)"); } }