Skip to main content
AP CSP course

F15 · Topic 3.12

Procedure call tracer

Match three arguments by position, follow a returned value into a caller expression and design a test that exposes a swapped-argument bug.

1. Predict first

quote(base,perItem,count)returns base+perItem*count. Predict quote(5,2,3)and quote(2,5,3), then the caller result quote(5,2,3)+1.

Change it · step through · explain

Change an input, predict what will happen, then advance one step. Read why the state changes, reset and experiment. This fixed teaching model does not save progress or award XP.

Ready · Make a prediction

Ready to experiment
  1. Input 15Waiting
  2. Input 22Waiting
  3. Input 33Waiting

Ready to experiment

Why: Predict the first change, then advance one step.

Try this: Change one input, predict the difference, then reset and compare.

2. Build your procedure

Write quote with its three parameters and RETURN. Trace each parameter and explain why replacing RETURN with DISPLAY breaks a caller that adds 1.

Use AP CSP pseudocode, a language you know, or precise plain language. Your code is not executed here. Use the classroom assignment to save your response.

3. Check boundaries

Public worked tests for the fixed model
InputExpectedWhy this case
base 5,perItem 2,count 3Return 11; caller plus 1 is 12Argument order and returned result.
base 2,perItem 5,count 3Return17Exposes a swap concealed by some inputs.
base 5,perItem 2,count 0Return5Zero items still retain the documented base charge.

4. Explain and reflect

Why would quote(4,4,3)be a weak test for swapping the first two arguments?

Model limits: A fictional arithmetic contract. It is not a pricing recommendation, payment system or general procedure interpreter.

Teacher guidance and scoring