Difference between revisions of "CSC111 Teller Machine Program"
(Created page with "--~~~~ ---- <br /> <source lang="python"> # tellerMachine1.py # D. Thiebaut # A simple example of a teller machine program. # The user enters the amount to withdraw, and the #...") |
|||
Line 2: | Line 2: | ||
---- | ---- | ||
<br /> | <br /> | ||
+ | <showafterdate after="20150209 12:00" before="20250209 12:00"> | ||
<source lang="python"> | <source lang="python"> | ||
# tellerMachine1.py | # tellerMachine1.py | ||
Line 46: | Line 47: | ||
</source> | </source> | ||
<br /> | <br /> | ||
+ | </showafterdate> | ||
<br /> | <br /> | ||
<br /> | <br /> |
Revision as of 17:26, 8 February 2015
--D. Thiebaut (talk) 16:25, 8 February 2015 (EST)
<showafterdate after="20150209 12:00" before="20250209 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>