DogWalker
is #1 from the from the 2025 AP Computer Science A Free Response problems.
https://apcentral.collegeboard.org/media/pdf/ap25-frq-computer-science-a.pdf
Part (a) walkDogs
method
public int walkDogs(int hour)
{
int dogsToWalk = Math.min(maxDogs, company.numAvailableDogs(hour));
company.updateDogs(hour, dogsToWalk);
return dogsToWalk;
}
Part (b) dogWalkShift
method
public int dogWalkShift(int startHour, int endHour)
{
int earnings = 0;
for(int hour = startHour; hour <= endHour; hour++)
{
int dogsWalked = walkDogs(hour);
earnings += dogsWalked * 5;
if((hour >= 9 && hour <= 17) || dogsWalked == maxDogs)
earnings += 3;
}
return earnings;
}
Java files with test code
DogWalkCompany.java
DogWalker.java
OneTest.java
2025 AP CS Exam Free Response Solutions
Help & comments
Get help from AP CS Tutor Brandon Horn
See an error? Question? Please comment below.
2025-05-10 comment
Anonymous
Do you think I will get points off if for part A i used wrong syntax instead of company.updateDogs(hour, dogs)
i just used updateDogs(hour, dogs)
Response
Calling a method with a correct implicit parameter is a key part of Question 1. My best guess is that this will be an explicit point in the scoring guidelines, possibly combined with calling company.numAvailableDogs(hour)
.
The scoring guidelines are typically released over the summer.