Exercise 2: Adding a New Shipping Discount Rule — Possible Solution ==================================================================== WHICH SUBPROBLEM NEEDS TO CHANGE ------------------------------ Only CalculateShipping (Subproblem 3) needs to change. Its logic currently reads: ALGORITHM CalculateShipping(discounted_subtotal) IF discounted_subtotal >= 75 THEN RETURN 0 ELSE RETURN 8 ENDIF The new requirement adds a third case - a $5 discount off the flat $8 shipping fee specifically for orders over $200 (after discount) that don't already qualify for free shipping. Since every order over $200 is also over $75, and the existing logic already gives those orders free shipping (returning 0), the new rule as literally stated wouldn't actually change anything in practice - it's worth flagging this to whoever wrote the requirement, since "over $200 gets a $5 shipping discount" is already fully subsumed by "over $75 gets fully free shipping." (If the intended new threshold was actually meant to sit BELOW the free-shipping threshold - for example, a partial discount between $50 and $75 - CalculateShipping would still be the only subproblem that needs updating, just with a genuinely new middle case added between the existing two.) WHY THE OTHER FOUR SUBPROBLEMS DON'T NEED TO BE TOUCHED ------------------------------ CalculateSubtotal only sums quantity times price - it has no awareness of discount tiers, shipping, or tax at all, so a shipping rule change is completely outside its own responsibility. ApplyDiscountTier only determines the percentage-off tier applied to the subtotal itself - it doesn't know or care what happens to shipping afterward. CalculateTax only computes tax on the discounted subtotal - shipping cost isn't even one of its inputs. ComputeCartTotal (the composition step) simply calls each subproblem and sums the results - it doesn't contain any of the actual shipping RULES itself, only the instruction to call CalculateShipping and add whatever it returns. Since the new requirement is entirely about how shipping cost is determined, and CalculateShipping is the one and only subproblem whose entire responsibility is "determine shipping cost," it is the only piece that could possibly need to change. WHY THIS WORKS AS AN ANSWER ------------------------------ The answer correctly isolates the change to the one subproblem whose stated responsibility matches the new requirement, explicitly checks each of the other four subproblems' own stated purpose to confirm none of them are involved, and goes further by actually reasoning about whether the new rule as stated changes any real behavior - rather than mechanically assuming every new requirement necessarily changes something.