# Cash Register - question understanding

Tell us what’s happening:
Hi, can anyone explain the question? what is `{status: "CLOSED", change: [...]}` and `{status: "OPEN", change: [...]}` supposed to show or what does that mean. what I infer from the question is that:

• here `change` should be: `change = cash - price;`

• if there is no exact `change` in the cash-register-drawer(`cid`) return `return {status: "INSUFFICIENT_FUNDS", change: []};` For example, we may have the amount but not exact coins and bills to give like we have a \$5 bill only but we need to return a quarter

• if there is no sufficient `change` in the cash-register-drawer(`cid`) return `return {status: "INSUFFICIENT_FUNDS", change: []};` For example, we do not have the required `change` in coins and bills to give back, like we have to return \$5 but we have a quarter only.

• here `status` key is the status of the cash register and `change` key is the amount returned to the customer. So when no amount has been returned the change key is `change:[]` and status of the cash register is `status: "INSUFFICIENT_FUNDS",`

• `{status: "OPEN", change: [...]}` would be returned when the cash-register-drawer(`cid`) possessed the exact amount of `change` to be returned in bills and coins. Here `change` would be the array of bills and coins that were returned from highest to lowest.
For example, if the `change` was \$1 and the cash-register-drawer(`cid`) had 6 quarters only, the `change` returned would be `change: [["QUARTER",1]]`.
What does `OPEN` represent here in this case as for the `status` of `cid` ??

• if `change = 0` would return be `{status: OPEN", change: []} ??

• In which case should function return `{status: "CLOSED", change: [...]}` ?? what would be the meaning of status `CLOSED` for `cid` and what would be returned as `change`? Please give an example of this particular case for clarity.

Here are the cases:

Return “Insufficient”

• if you can’t give the exact change. e.g) The change is \$3 and you only have a \$5 bill.
• if you can’t afford a change. e.g) The change is \$3 and you only have \$1 in the register.

Return “Closed”

• Register is empty after giving a change. e.g) The change is \$1 and you have a \$1 worth of cash.
The return value is all cash in the register just before you give the change.

(I don’t know terminologies for the real life cash registers, but “Empty” makes more sense than “Closed”.
“Closed” sounds like if the cash register is physically locked.)

Return “Open”

• In any other cases. i.e) You can give exact change and you are still left with some cash in your register.

The case when `change = 0` seems open ended; but, in this case, it should either be “Closed” or “Open” depending on the cash flow in the register because it makes sense to do so.

4 Likes

Thank you so much for making it clear!