Bottle is #2 from the from the 2026 AP Computer Science A Free Response problems.
https://apcentral.collegeboard.org/media/pdf/ap26-frq-computer-science-a.pdf
Bottle class
public class Bottle
{
private final double capacity;
private double amountRemaining;
public Bottle(double capacity)
{
this.capacity = capacity;
amountRemaining = capacity;
}
public double updateAmount(double amountUsed)
{
final double MIN_PERCENT_LEFT = 0.25;
amountRemaining -= amountUsed;
if(amountRemaining < capacity * MIN_PERCENT_LEFT)
amountRemaining = capacity;
return amountRemaining;
}
}
See Class writing order for details on how to approach free response that request writing an entire class.
Java files with test code
2026 AP CS Exam Free Response Solutions
- Account free response answer 2026
- Attendance free response answer 2026
- GameBoard free response answer 2026
Help & comments
Get help from AP CS Tutor Brandon Horn
See an error? Question? Please comment below.