Skip to main content

Question 3: Data Analysis with ArrayList

Biggest day-to-day warm-up

  • Unit 4
  • 5 points
  • About 18 minutes

You write one method that traverses, analyzes or changes data stored in an ArrayList of objects, using the classes described in the question. New since the course was revised for 2025–26 (first tested in May 2026): it's always an ArrayList now (it used to be an array or an ArrayList), it's worth 5 points instead of 9, and points are no longer taken off as penalties. On the exam: Question 3 of 4, 5 points. Section II has 4 free-response questions in 90 minutes (45% of the score), all assessing Practice 2 (Develop Code). The exam is fully digital in Bluebook: you type your Java, and the Java Quick Reference is provided. No calculator. Suggested time is our split of the 90 minutes by points; College Board gives no per-question timing.

The question and its sources

A weather station records each day's high temperature. A Reading object stores the day's label and its high, and the WeatherLog class keeps the readings for consecutive days in an ArrayList, oldest first.

The Reading class

Java
public class Reading
{
    /** Returns the label for the day, such as "Mon" */
    public String getDay()
    { /* implementation not shown */ }
 
    /** Returns the day's high temperature, in whole degrees */
    public int getHigh()
    { /* implementation not shown */ }
 
    // There may be instance variables, constructors, and methods that are not shown.
}

The WeatherLog class

Java
public class WeatherLog
{
    /**
     * Readings for consecutive days, oldest first.
     * Contains at least 2 readings and no null elements.
     */
    private ArrayList<Reading> readings;
 
    /**
     * Returns the label of the day whose high rose the most compared
     * with the day before it, as described in the question.
     * Postcondition: readings is unchanged.
     */
    public String biggestWarmUp()
    { /* to be implemented */ }
 
    // There may be instance variables, constructors, and methods that are not shown.
}

Example: the readings in one log

Index012345
getDay()"Mon""Tue""Wed""Thu""Fri""Sat"
getHigh()616458667074

Source: Hypothetical example

Suggested time: 18 minutes

Your answers are saved in this browser as you type.

Something wrong with this question?

What's wrong?

Please don't include personal details.

Part (a)

5 points

A day's *warm-up* is its high minus the high of the day before it. The first day in the log has no warm-up. Write the WeatherLog method biggestWarmUp, which returns the day label of the reading with the largest warm-up that is greater than 0. If two or more days tie for the largest warm-up, return the earliest of them. If no day is warmer than the day before it, return "none". For the example above, the warm-ups for Tue through Sat are 3, −6, 8, 4 and 4, so biggestWarmUp returns "Thu". For a log with highs of 80, 75 and 75, it returns "none". Complete method biggestWarmUp.public String biggestWarmUp()

Tab indents. Press Esc, then Tab, to move on.

0 lines · 0 / 2,500 characters

Checking scoring…

Scoring it yourself shows you the rubric, examples and a model answer. Try writing your answer first.