+ 4

Challenge: Exact Change.

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. cid is a 2D array listing available currency. Return the string "Insufficient Funds" if cash-in-drawer is less than the change due. Return the string "Closed" if cash-in-drawer is equal to the change due. Otherwise, return change in coin and bills, sorted in highest to lowest order. EXAMPLES: checkCashRegister(3.26, 100.00, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.10], ["QUARTER", 4.25], ["ONE", 90.00], ["FIVE", 55.00], ["TEN", 20.00], ["TWENTY", 60.00], ["ONE HUNDRED", 100.00]]); // should return [["TWENTY", 60.00], ["TEN", 20.00], ["FIVE", 15.00], ["ONE", 1.00], ["QUARTER", 0.50], ["DIME", 0.20], ["PENNY", 0.04]] checkCashRegister(19.50, 20.00, [["PENNY", 0.01], ["NICKEL", 0], ["DIME", 0], ["QUARTER", 0], ["ONE", 1.00], ["FIVE", 0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]]) //should return "Insufficient Funds". checkCashRegister(19.50, 20.00, [["PENNY", 0.50], ["NICKEL", 0], ["DIME", 0], ["QUARTER", 0], ["ONE", 0], ["FIVE", 0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]]) //should return "Closed". Have Fun! reference: https://www.freecodecamp.org/challenges/exact-change

21st Sep 2017, 1:07 PM
ysraelcon
ysraelcon - avatar
3 odpowiedzi
+ 7
Here's my C# implementation! ✌ This is probably the longest code I've written in SoloLearn so far and I'm happy to complete the challenge! I've tried to use appropriate data structures offered by C# and make it as clean as possible. Thank you for the challenge and I hope somebody will enjoy reading my code~ 😄 https://code.sololearn.com/cV5ZAvq30Pj9/?ref=app
22nd Sep 2017, 4:53 AM
Zephyr Koo
Zephyr Koo - avatar
+ 3
PENNY: 0.01 NICKEL: 0.05 DIME: 0.10 QUARTER: 0.25 ONE: 1.00 FIVE: 5.00 TEN: 10.00 TWENTY: 20.00 ONE HUNDRED: 100.00
21st Sep 2017, 12:42 PM
ysraelcon
ysraelcon - avatar
0
we dont use penny nickle dime please post the interrelation between them
21st Sep 2017, 4:06 AM
sayan chandra
sayan chandra - avatar