Floating-point numbers

F-FLOAT-V4-2medium

Check the payment

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 status so each payment is reported as ok, short or over against the total, to the cent.

Reproduce

  1. Compile and run the two-payment sample with g++, then compare every verdict with the expected stdout.

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 receipt per line, the amount paid followed by the prices, each with two decimals.

Supported input: finite nonnegative prices and payment with exactly two decimal digits; at most 100 prices per receipt; each price, total and payment at most 99999.99. Supplied readers receive valid data within these bounds.

Sign in to open this exercise

The ticket brief is public. Sign in to access the exercise. Paid exercises require Pro.

Sign in