Computer Science 111 - Fall Semester, 2006. Homework #2
due: by midnight Wednesday night September 20.

Part 0. Remarks about programming in pairs.
The most successful partners are those who equally share the typing. Also, partners often work on code by themselves, especially when projects are large. However, they never insert one partner's code without running, reviewing, and testing that part together and within the whole program. Furthermore, they would always communicate about how the program is going, and never wait until the last minute to merge two large, overlapping programs!

That said, suppose one partner has worked on part of a program and called it p1.py and the other partner has worked on a file called hw2.py. How do we put them together?

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.
  • Then comes the part of your code you wrote in the lab where you ask the user for the bills that she is depositing
  • Next write Python statements in the definition of main that:
    1. Ask the user for the coins that she is depositing, after asking about the number of bills. Ask for these values in the same order as the book shows on page 52:
      • Quarters
      • Dimes
      • Nickels
      • Pennies
      The order of inputs is very important, and must follow the specifications.
    2. Compute the total amount of money, from all the bills and all the coins, that she is depositing and tell the user the total.
    3. Be sure to test this first part of the program thoroughly before moving on.
    Now, you will add a part that allows the user to make a withdrawal
    1. Ask her how much money she wants to withdraw, and put this into a variable. This will be a floating point number.
    2. Compute how many twenty-dollar, ten-dollar, five-dollar, one dollar bills, and quarters, dimes, nickels, and pennies, that the machine will have to give to the user. You will use the modulus operator, %
    3. Tell the user how many twenty-dollar bills, etc., she will receive (i.e., print the values that you computed in step 2).
    4. Of course, we're not really giving anybody any money - so figure out something clever to tell the user about where she can go to get her withdrawal money.

    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.