Extra Credit 2

Due: October 26, 2023
Points: 24


  1. (24 points) In the make_change.py program, change the output to reflect the following:
    1. If there is exactly 1 quarter, dime, nickel, or penny, your output uses the singular for the coin
    2. If there is more than 1 quarter, dime, nickel, or penny, your output uses the plural for the coin
    3. If there are no quarters, dimes, nickels, or pennies, do not print that coin
    4. If a non-positive integer, or a non-integer, is entered, give the error message “bad input; must be a positive integer” and quit
    5. If there are two different types of coins, put an “and” between them
    6. If there are three or more types of coins, put a comma after each type of coin except the last, and put an “and” between the last two types of coins.

    To turn in: Please turn in the program in the file new_make_change.py.

    Examples:

    
    Amount of change: 92
    92 cents is 3 quarters, 1 dime, 1 nickel, and 2 pennies
    
    
    Amount of change: 16
    16 cents is 1 dime, 1 nickel, and 1 penny
    
    
    Amount of change: 15
    15 cents is 1 dime and 1 nickel
    
    
    Amount of change: 30
    30 cents is 1 quarter and 1 nickel
    
    
    Amount of change: 34
    34 cents is 1 quarter, 1 nickel, and 4 pennies
    
    
    Amount of change: 1
    1 cent is 1 penny
    

UC Davis sigil
Matt Bishop
Office: 2209 Watershed Sciences
Phone: +1 (530) 752-8060
Email: [email protected]
ECS 235A, Computer and Information Security
Version of October 13, 2023 at 7:52PM

You can also obtain a PDF version of this.

Valid HTML 4.01 Transitional Built with BBEdit Built on a Macintosh