Skip to content

Commit d4f8e07

Browse files
committed
added test cases
1 parent 47b0c4b commit d4f8e07

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

Cash_Register/Cash_Register.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Cash Register
2+
Design a cash register drawer function `checkCashRegister()` that accepts purchase price as the first argument `(price)`, payment as the second argument `(cash)`, and cash-in-drawer `(cid)` as the third argument.
3+
4+
`cid` is a 2D array listing available `currency`.
5+
6+
The `checkCashRegister()` function should always return an object with a `status key` and a `change ke`y.
7+
8+
Return `{status: "INSUFFICIENT_FUNDS", change: []}` if cash-in-drawer is less than the change due, or if you cannot return the exact change.
9+
10+
Return `{status: "CLOSED", change: [...]}` with cash-in-drawer as the value for the key change if it is equal to the change due.
11+
12+
Otherwise, return `{status: "OPEN", change: [...]}`, with the change due in coins and bills, sorted in highest to lowest order, as the value of the change key.
13+
14+
|Currency Unit |Amount |
15+
- | -
16+
|Penny |$0.01 (PENNY)|
17+
|Nickel |$0.05 (NICKEL)|
18+
|Dime |$0.1 (DIME)|
19+
|Quarter |$0.25 (QUARTER)|
20+
|Dollar |$1 (ONE)|
21+
|Five Dollars |$5 (FIVE)|
22+
|Ten Dollars |$10 (TEN)|
23+
|Twenty Dollars |$20 (TWENTY)|
24+
|One-hundred Dollars |$100 (ONE HUNDRED)|
25+
26+
See below for an example of a cash-in-drawer array:
27+
```
28+
[
29+
["PENNY", 1.01],
30+
["NICKEL", 2.05],
31+
["DIME", 3.1],
32+
["QUARTER", 4.25],
33+
["ONE", 90],
34+
["FIVE", 55],
35+
["TEN", 20],
36+
["TWENTY", 60],
37+
["ONE HUNDRED", 100]
38+
]
39+
```

0 commit comments

Comments
 (0)