← Back
Code Challenge 1.7 - Change Calculator
Objective
Your task is to write a program that helps novice cashiers give back the correct change efficiently. The program should start with the largest coin denomination and work its way down until the exact change is given.
Example: If a cashier needs to return 55 cents, your program should display: two quarters and one nickel. While there are other combinations, this method ensures efficiency.
Skills to Practice
- Prompting a user for input
- Saving user input to variables
- Converting input to the correct data type (if necessary)
- Performing arithmetic calculations
- Formatting custom output using variables
Challenge Tasks
- Create a console project named Challenge 1-7.
- Prompt the user to input the amount of change needed. For simplicity, assume the value will range from 1 to 99 cents.
- Calculate the change starting with the largest denomination (quarters) and work down to the smallest (pennies).
- Display the result in a clear and concise format.
Sample Output
Enter the amount of change needed (in cents): 68 [Enter]
You will need:
2 quarters
1 dime
1 nickel
3 pennies