AP CSA 1.1 FRQ Practice: Delivery Route

Unit 1: Using Objects and Methods · Lesson 1.1 · FRQ Practice

Delivery Route

A free response question in the shape the exam uses: a stated contract, four rubric parts, and no main method handed to you. Worth 4 points.

Why this question is worth four points

An algorithm is an ordered sequence of steps, and on the exam the order is graded. This question hands you three leg distances and asks for four reported values, each of which depends on the ones before it. A student who computes the final answer in one expression gets that answer right and the intermediate rows wrong, which is exactly how partial credit is lost.

What you are given

Three int variables legA, legB and legC are already declared and assigned for you. You do not declare them and you do not read any input.

The question

  1. (a) Print the total distance of all three legs.
  2. (b) Print the distance remaining after the first leg is driven.
  3. (c) Print the average leg distance as an int, using integer division.
  4. (d) Print the length of the longest single leg, using Math.max.

What the reader is looking for

  1. Write a code segment that prints four lines, one per rubric part, in order (a) through (d).
  2. Part (c) is integer division on purpose. 100 / 3 is 33, not 33.333, and the exam expects 33.
  3. Part (d) has no if statement available to you. Math.max takes two arguments, so use it twice.

Worked examples

These show what a correct answer prints. There are more cases you cannot see, and they use different values, so an answer built around just these numbers will fail.

Example 1 is given
int legA = 12;
int legB = 30;
int legC = 18;
Example 1 output
60
48
20
30
Example 2 is given
int legA = 20;
int legB = 20;
int legC = 21;
Example 2 output
61
41
20
21

Your answer

Main.java

Input for the Run button

How this is scored: your answer runs against every test case, and the fraction it passes becomes your score out of 4. That is not how a human AP reader marks a rubric, so treat the score as a check on whether your code works, and the rubric above as the thing you are actually practising.


  

  

Stuck?

Hint 1

Compute the total once into a variable and reuse it. Part (b) is the total minus legA, and writing legB + legC instead is correct here but stops being correct the moment the question changes.

Hint 2

Integer division truncates toward zero. There is no rounding in part (c) and no cast to double: 25 / 2 is 12.

Hint 3

Math.max only compares two values. Math.max(a, Math.max(b, c)) compares all three without a single if.

Before you submit

2 mistake(s) that lose points on this question

Each of these is a real error the grader catches. Check your answer against them before you submit, not instead of trying.

  • part (d) compares only the first two legs
  • part (c) averages as a double instead of using integer division

Where to go next

Get in Touch

Whether you're a student, parent, or teacher — I'd love to hear from you.

Just want free AP CS resources?

Enter your email below and check the subscribe box — no message needed. Students get daily practice questions and study tips. Teachers get curriculum resources and teaching strategies.

Typically responds within 24 hours

Message Sent!

Thanks for reaching out. I'll get back to you within 24 hours.

🏫 Welcome, fellow educator!

I offer curriculum resources, practice materials, and study guides designed for AP CS teachers. Let me know what you're looking for — whether it's classroom materials, a guest speaker, or Teachers Pay Teachers resources.

Email

[email protected]

📚

Courses

AP CSA, CSP, & Cybersecurity

Response Time

Within 24 hours

Prefer email? Reach me directly at [email protected]