Hi all, I have just started out in C++ am trying to write up a cash dispenser code upon entered amount(assuming it as whole numbers - 100, 220 etc..) and to list out the least number of bills, butthe machine only dispense 20 and 50 bills.
So far I am able to write my code by first dividing the entered amount by 50, then by 20 (amount reduction of the 50s)
However while doing so, I realize that should I entered in an amount, say 480, I will be getting 9 bills of 50 and a bill of 20 as my output (a missing 10 amount here), in which it should be 8 bills of 50 and 4 bills of 20.
I am somewhat lost and was wondering if anyone give me any pointers on how I should approach this?
Pardon me if I sounded stupid but will that be a while loop? So far I have try covering topics like if else, for, while loops etc on my own and so am not exactly sure when to use which depending on scenario.
The coding I have been writing uses on if else and unfortunately I believe I am brute forcing through which is not ideal at all