CSC111 Teller Machine Program
--D. Thiebaut (talk) 16:25, 8 February 2015 (EST)
<showafterdate after="20180212 12:00" before="20180601 12:00">
# tellerMachine1.py
# D. Thiebaut
# A simple example of a teller machine program.
# The user enters the amount to withdraw, and the
# program figures out the number of bills to give out.
def main():
# get the amount to withdraw from the user.
amount = int( input( "How much money do you need? " ) )
# compute the number of bills in various denominations
no20s = amount // 20 # integer number of $20-bills
leftOver = amount % 20 # remainder of amount divided by 20
no10s = leftOver // 10 # integer number of $10-bills in
# left-over
leftOver = leftOver % 10 # left-over of the left-over once we take
# the $10 bills away
no5s = leftOver // 5 # integer number of $5-bills
leftOver = leftOver % 5 # left-over of the left-over after we take
# the $5 bills away
no1s = leftOver
# output the results for the user, in # bills given out by the machine.
print()
print( no20s, "$20-bill(s)" )
print( no10s, "$10-bill(s)" )
print( no5s, "$5-bill(s)" )
print( no1s, "$1-bill(s)" )
print()
main()
</showafterdate>