Back

Code Challenge: Change Calculator

Difficulty  

divider

Objective

Help a novice cashier give back the correct change. Start with the largest coin denomination and work down until the exact change is given.

This one leans on floor division and modulus from Activity 1.4 — floor division tells you how many of a coin fit, and modulus tells you what is left over.

Skills to Practice

  • Prompting a user for input
  • Saving user input to variables
  • Converting input to the correct data type
  • Performing arithmetic calculations
  • Formatting custom output using variables
  • Using floor division and modulus together

Tasks

  • Create a new Python program named cc-change-calculator.
  • Prompt the user for the amount of change needed, in cents. Assume a value from 1 to 99.
  • Work out the change starting with the largest denomination (quarters) down to the smallest (pennies).
  • Display the result in a clear, concise format.

Sample Output

Sample Output
Enter the amount of change needed (in cents): 68 [Enter]
You will need:
2 quarters
1 dime
1 nickel
3 pennies

Commence Challenge