Answered step by step
Verified Expert Solution
Question
00
1 Approved Answer
Exercise 2 (60 points): Write a program that helps a cashier make change. The program gets a dollar amount from the user and calculates and
Exercise 2 (60 points): Write a program that helps a cashier make change. The program gets a dollar amount from the user and calculates and displays how to make the change using the smallest number of bills and coins possible. (The change should be made by first giving the maximum number of dollars, followed by the maximum number of quarters, then dimes, nickels, and finally pennies. i.e. Your answer should never have more than 3 quarters, 2 dimes, 1 nickel, or 4 pennies.) You may assume that only amounts greater than $0 will be entered. Hint: To avoid problems with the lack of precision that exists in floating-point values you may want to convert the amount entered by the user to pennies and use integer arithmetic. Sample output of a program that satisfies the requirements is shown below. The data entered by the user is in blue. Sample Output 1: Enter the amount: 11.92 Change due: 11 dollars 3 quarters 1 dimes 1 nickel 2 pennies Sample Output 2: Enter the amount : 4.14 Change due: 4 dollars 0 quarters 1 dimes O nickel 4 pennies Sample Output 3: Enter the amount: 64.99 Change due: 64 dollars 3 quarters 2 dimes 0 nickel 4 pennies Page 2 of 3
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started