Round the discount
A receipt terminal prints totals, checks payment to the cent and applies whole-percentage discounts to supported finite nonnegative amounts.
What needs to change
Repair discountCents so each discount is rounded to the cent, with half a cent rounding up.
Reproduce
- Compile and run the sample discounts with g++, then use Check work for the other prices and percentages.
Acceptance criteria
Your review marks · Saved in this browser. Test acceptance is tracked separately.
Notes
The file contains its headers, readLines, formatAmount and main. The browser compiles with g++ -std=c++23.
Input: one item per line, a price with two decimals and a whole percentage passed as an int.
Supported input: a finite nonnegative two-decimal price at most 99999.99 and a whole discount percentage from 0 to 100. Supplied readers receive valid data within these bounds.