2025 AP Computer Science A FRQ #1B

Write the dogWalkShift method, which performs a dog-walking shift of the hours in the range startHour to endHour, inclusive, and returns the total amount earned. For example, a dog-walking shift from 14 to 16 is composed of three one-hour dog walks starting at hours 14, 15, and 16. For each hour, the base pay is $5 per dog walked plus a bonus of $3 if at least one of the following is true. • maxDogs dogs are walked • the walk occurs between the peak hours of 9 and 17, inclusive The following table shows an example of the calculated amount earned by walking dogs from hour 7 through hour 10, inclusive. Complete method dogWalkShift. Assume that walkDogs works as specified, regardless of what you wrote in part (a). You must use walkDogs appropriately to earn full credit. Intro: 00:00 Writing the pseudocode: 01:03 Writing the code: 03:25 Testing the code: 08:19 Final solution: 13:33