Question: CSC A08 TERM TEST #1 Winter 2017 Question 3. [10 MARKS] A clerk works in a store where the cost of each item is a
CSC A08 TERM TEST #1 Winter 2017 Question 3. [10 MARKS] A clerk works in a store where the cost of each item is a positive number of dollars. So, for example, something may cost $12, but nothing costs $5.99. In order to make the change, the clerk as an unbounded number of dollar bills in each of the following denominations: $1, $2, $5, and $10. Write a function called give.change that prints directions to a cashier how to give the change to a customer. The function does not return any value. It takes two integer values: the paid amount from the customer expressed in dollars, and the amount cost also expressed in dollars. The change must be paid using the smallest possible muber of bills. You MUST USE DICTIONARIES to solve this problem. No credit will be given to solutions which do not use dictionaries in a meaningful way. An example of use of this function is shown below: give_change (200, 178) This call must produce the following output on the console: 2 $10 dollar bil1(s) 1 $2 dollar bil1(s) Please note there are many ways to make the $22 change for example, one may use one $5 bill and seventeen 1$ bills, however we are looking for a solution that makes the change using the smallest possible number of bills. In the example above, the change is $22 and we have a solution that pays is using 3 bills; to reduce number of bills, we have to substitute a number of smaller denomination bills with a bigger denomination bills, however we have no bills larger than $10 and the single $2 bill cannot be replaced any further. def give_change (paid, cost): (int, int) ->NoneType Computes the change (paid cost) and prints instructions how to give it using the minimal amount of bills of the following denominations: $1, $2, $5, and $10 dollars. Example: give.change (50, 12) must print the folloving: 3 10 dollar bill(s) 1 $5 dollar bill (s) 1 $2 dollar bill(s) 1 $1 dollar bill(s) # Your code goes on the next page. resu chont/10 +, $10 doller
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
