function ATMCashOutCount(amount) cash = {} cash.hundred = math.floor(amount/100) --[[returns number of items needed to give equivalant to x number of $100 bills]] cash.fifty = math.floor((amount%100)/50) cash.twenty = math.floor((amount%50)/20) cash.ten = math.floor((amount%20)/10) cash.five = math.floor((amount%10)/5) cash.dollar = math.floor(amount%5) if cash.hundred > 0 then io.write(cash.hundred.."x$100, ") end if cash.fifty > 0 then io.write(cash.fifty.."x$50, ") end if cash.twenty > 0 then io.write(cash.twenty.."x$20, ") end if cash.ten > 0 then io.write(cash.ten.."x$10, ") end if cash.five > 0 then io.write(cash.five.."x$5, ") end if cash.dollar > 0 then io.write(cash.dollar.."x$1") end end input = read() ATMCashOutCount(input)
When I run it and input 70, i get 1x50, 1x20, 1x10 (=80)
How do i remove the first result from the second?
in other words
770 =
7x100 then
70 is left, subsequently 70/50 floored is 1, remaining 20 which means 1x20 completes the calculation with no 10s remaining.
Each result will then be passed to a command block to give the correct custom items chosen for my economy which is why I cant have any rogue 10s etc.
on another note if i input 80, i get 1x50, 1x20 (=70) so there seems to be a small bug to "flush" out
Do i need to code it differently? Cheers in advance.
Edited by CreeperGoBoom, 13 December 2018 - 06:20 AM.