Question: Exercise 2 : Write a program to calculate change from a transaction. Create a variable for the cost of some item and the size of

Exercise 2: Write a program to calculate change from a transaction.
Create a variable for the cost of some item and the size of the bill a customer pays with. Assign some values of your choice
to your variables.
Find the total change owed the customer by subtracting item cost from amount paid. NOTE: Due to rounding in the
computer, your final result might be off by 1 cent. As a quick fix add 0.001 to this difference. There are better ways to fix
this, but not with our current material, so we'll go with this.
Determine the exact breakdown of bills and/or coins owed the customer using the divmod() function. You should
minimize the number of bill/coins returned using standard U.S. currency: $100,$50,$20,$10,$5,$1,25c,10c,5c, and 1 c .
Remember that divmod returns two outputs, one from integer division and one from modulo.
Use print function to output the breakdown.
For example, a customer might buy something for $3.20 with a $50 bill. They are owed a total of $46.80 in change. This would
be two $20 bills, one $5 bill, one $1 bill, three quarters, and a nickel.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!