Skip to main content

Checkpoint: debug & repair lab

Challenge on lesson: Checkpoint: Debug & Repair Lab

Three customers report: changeFor(0) prints "0q 0d 0n 0p" (good), changeFor(97) prints "3q 2d 1n 2p" (good), but changeFor(-5) prints "0q 0d -1n 0p" (nonsense) and changeFor(41) prints "1q 1d 1n 2p"... except one of these two reports is a lie. Reproduce with main, find the real defect, and fix it so: negative input throws IllegalArgumentException with a message containing "negative", and every amount 0..99 produces the exact correct breakdown (verified by your own main and by the tests).

Difficulty: advanced

Back to lesson: Checkpoint: Debug & Repair Lab