Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question6. (4 points) Suppose that a cashier owes a customer some change and that the cashier only has coins ie. quarters, dimes, nickels and pennies

image text in transcribed
Question6. (4 points) Suppose that a cashier owes a customer some change and that the cashier only has coins ie. quarters, dimes, nickels and pennies ( 25 cent, 10 cent, 5 cent, and 1 cent coins). Write a Python function named min_coins that determines the minimum number of coins that the cashier can return. The function doesn't take any parameter, reads the dollar amount from the keyboard, calculates the minimum number of coins owed to the customer and returns it. Use the following algorithm. The program (function body) must read the amount from the keyboard (consider that the value entered will be positive). Next, calculate the possible number of quarters. If there is a remainder, calculate the number of dimes, then nickels, and finally pennies, as needed. To test, call the function, and provide the value of the amount (positive number) to display the result indicated by the function. Example: If the cashier must return $0.56, the minimum number of coins is 4 ( 2 quarters, 0 dimes, 1 nickel and 1 penny). It is not possible to give 3 coins (or less). If the amount to be returned is 1.42 dollars, the minimum number of coins is 9 (5 quarters, 1 dime, 1 nickel and 2 pennies). Help: Multiply the dollar amount with 100 to use after modulo 25, 10, 5 (because modulo is an operator that takes integers as operands)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions