Skip to content

feat(cpp): add cash register example with greedy change + integer cents#382

Open
syedk03 wants to merge 1 commit intodiwas7777:mainfrom
syedk03:feat/cash-register
Open

feat(cpp): add cash register example with greedy change + integer cents#382
syedk03 wants to merge 1 commit intodiwas7777:mainfrom
syedk03:feat/cash-register

Conversation

@syedk03
Copy link

@syedk03 syedk03 commented Dec 11, 2025

Summary
Adds a cash register example that returns {status, change} from price, cash, and cid. Uses greedy change with integer cents to avoid floating-point error. Produces OPEN, CLOSED, or INSUFFICIENT_FUNDS and a denomination breakdown.

Test/Demo cases
19.50 → 20.00 with quarters available → OPEN, [["QUARTER", 0.5]]
Exact drain drawer → CLOSED, change equals original cid
Not enough composition → INSUFFICIENT_FUNDS, []

Notes
Clear comments explaining the approach and edge cases.
No external dependencies; simple compile/run (C++) or node (JS).

Issue
Closes #378.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a Cash Register Program in Cpp

1 participant