Exercise 3: Applying IPO and Decomposition to a Grading Problem — Possible Solution ==================================================================== THE IPO TABLE ------------------------------ Input: A list of students, each with a numeric test score Processing: Convert each numeric score into a letter grade; compute the class's overall average score Output: Each student's letter grade, plus the single class average Exactly as in this chapter's own cart example, the "Processing" row here is doing too much to write pseudocode for directly - it names two genuinely separate computations (per-student grading, and a class-wide average), which is the same signal this chapter used to decide the cart problem needed decomposing further. EXPECTED FIRST-LEVEL SUBPROBLEMS ------------------------------ 1. Calculate class average - sum all scores, divide by the number of students - a self-contained numeric computation, no grading logic involved 2. Convert a single score to a letter grade - given one numeric score, apply threshold rules (for example, 90+ = A, 80-89 = B, 70-79 = C, 60-69 = D, below 60 = F) - operates on exactly one score at a time, independent of the rest of the class 3. Apply the grade conversion to every student - loop over the full student list, calling Subproblem 2 once per student, building up a list of (student, grade) results 4. Produce the final report - combine Subproblem 3's own list of per-student grades with Subproblem 1's own class average into the final output format WHY THIS SPLIT FOLLOWS THIS CHAPTER'S OWN STOPPING RULE ------------------------------ Each of these four pieces is now small enough to write pseudocode for directly using only sequence, selection (the grade thresholds), and iteration (looping over students) - exactly the "can I now write straightforward pseudocode for this piece" test this chapter established, without needing a further level of decomposition the way the original combined "Processing" row did. WHY THIS PARALLELS THE CART EXAMPLE STRUCTURALLY ------------------------------ Subproblem 2 here plays the same role CalculateTax or CalculateShipping played in the cart example - a small, single-purpose calculation with no dependency on the others. Subproblem 3 mirrors how this chapter's own composition step (ComputeCartTotal) called each smaller piece in sequence; the difference here is that Subproblem 3 calls Subproblem 2 repeatedly, once per student, rather than calling several different subproblems once each - a natural variation the same top-down discipline still handles cleanly. WHY THIS WORKS AS AN ANSWER ------------------------------ The answer produces a genuine IPO table for the new problem rather than reusing the cart example's own table, correctly identifies the same "processing row doing too much" signal, and derives a first-level decomposition whose pieces each pass the chapter's own stopping-rule test, explicitly drawing the structural parallel to the cart example rather than treating the two problems as unrelated.