Its been awhile since I've programmed but if you write a loop that first checks the largest monetary value then works its way ot the smallest amount until no number is left.
Use the largest demonination possible(1 dollar) you cant any more then subtract that from the total, and repeat with the smaller coins until you have nothing left.
make sure you restart the loop after the largest denomitor is used up
After reading this back ot myslef it doesn't make too much sense but I hope this helps.
if the change is 158
while change != 0
if change>=100 then
while change>=100
change=change-100
dolar=dolar+1
break off and start over
if change>=25 then
while change>=25
change=change-25
quarter++
break
and go on with the rest of the change amounts.
thats generally how i I would do it minus the sytanx but you would probably get the idea.
or you could do it with the mod function like the guy above said ;)
Log in to comment