Computer Science 111 - Fall Semester, 2006. Homework #2
Part 0. Remarks about programming in pairs.
emacs hw2.pyNow you are in emacs, move the cursor (using your emacs commands or the arrow keys) to the exact place where you want to insert the file p1.py. Now type
esc xNote that the esc key works differently than the ctrl key. Just hit the esc key and release it and then type x. Underneath the thick black line on the bottom of the emacs screen you should see M-x and the cursor beside it, waiting for your command. Type
insert-fileand hit Enter. You should next see this prompt:
Insert file: ~/with the cursor beside it. Just type the file you want to insert, p1.py and hit Enter. You should see the file p1.py inserted in the emacs window.
Part 1.
Your task in this project is to make the automated teller machine program that you developed in lab more useful. It will begin as in lab. Start by typing cp lab2.py hw2.py and make sure that your function is called main. In other words
def main():should be at the top of your program.
Step #2 in part 2 will be the most challenging. Here's my suggestion for how to do it:
First, convert the amount of money, which is a real number, to two integers that represent the total number of dollars and the total number of cents (and store these into two integer variables. Use the integer function to make sure they are integers). So, e.g., you'd convert 28.13 to the two integers 28 and 13. You can then determine the number of each type of bill by working with the total number of dollars, and the number of each type of coin by working with the total number of cents. The modulus operation, %, and integer division are the two main tools for this part of the program.
Important note: We use software to test your
program, so it is important that the input your program expects is exactly
what is specified on the assignment:
first, the number of 20-dollar bills, 10-dollar bills,
5-dollar bills, 1-dollar bills,quarters, dimes, nickels, pennies, that
the user is depositing, followed by the single amount that she wishes
to withdraw.
Do not ask
the user for her name any other input in this program.
Your final program should be in a file called hw2.py
your program should be defined as function main.
Do not place a call to main() at the bottom of the file!
Make sure you have included both partners' names and account names in the comments at the top,
as well as the correct file name, date, and description of the
program. Partners should only submit one copy of
the program, using one of your accounts. After you have this documentation fixed up, reinterpret
the program in case you introduced any weird characters.
Submit this homework by the due date with the command
submit homework2 hw2.py
You should make sure that both partners have an up-to-date copy of the program you submitted. Use sftp for this purpose.