In a store, you want to give change to customers and only have coins of the following types: 25 cents, 10 cents, 5 cents, and 1 cent. Write a Python function called currency (n) to calculate the minimum number of coins the cashier can donate, or n is a real (float). The function takes as input in parameter the value n in dollars. Use the following algorithm: multiply the dollar value with 100 to turn it into cents (pennies). Next, calculate the possible number of 25-cent coins. If there is a remainder, calculate the number of dimes, then 5 cents, and finally 1 cent, if necessary. The function should display the number of 25 cents, 10 cents, 5 cents, and 1 cent coins, as shown in the photo. And at the end the function should return the minimum total number of parts, which is an integer (int). Use modulo and integer division for calculations. Examples: If the cashier has to return $ 0.56, the minimum number of coins is 4 (2 coins of 25 cents, 0 10 cents, 15 cents and 1 1 cent). It is not possible to give 3 pieces (or less) so the minimum number in this case is 4. - If the amount to be returned is $ 1.42, the minimum number of coins is 9 (5 coins of 25 cents, 1 10-cent coin, 1 5-cent coin and 2 1-cent coins).

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Please help I’m not understanding, also if you could explain the steps, thank you
In a store, you want to give change to customers and only have coins of the following types: 25
cents, 10 cents, 5 cents, and 1 cent.
Write a Python function called currency (n) to calculate the
minimum number of coins the cashier can donate, or n is a real (float).
The function takes as input in parameter the value n in dollars. Use the following algorithm:
multiply the dollar value with 100 to turn it into cents (pennies).
Next, calculate the possible number of 25-cent coins. If there is a remainder, calculate the
number of dimes, then 5 cents, and finally 1 cent, if necessary. The function should display the
number of 25 cents, 10 cents, 5 cents, and 1 cent coins, as shown in the photo.
And at the end the function should return the minimum total number of parts, which is an
integer (int). Use modulo and integer division for calculations.
Examples:
- If the cashier has to return $ 0.56, the minimum number of coins is 4 (2 coins of 25
cents, 0 10 cents, 1 5 cents and 11 cent). It is not possible to
give 3 pieces (or less) so the minimum number in this case is 4.
- If the amount to be returned is $ 1.42, the minimum number of coins is 9
cents, 1 10-cent coin, 1 5-cent coin and 2 1-cent coins).
coins of 25
>>>#test Q7
>>> numMonnaies (1.56)
6 pieces de 25 cents, 0 pieces de 10 cents, 1 pieces de 5 cents, 1 pieces de 1 cent
8
>>> numMonnaies (1.42)
5 pieces de 25 cents, 1 pieces de 10 cents, 1 pieces de 5 cents, 2 pieces de 1 cent
9.
>>> numMonnaies (1)
4 pieces de 25 cents, 0 pieces de 10 cents, 0 pieces de 5 cents, 0 pieces de 1 cent
4
Transcribed Image Text:In a store, you want to give change to customers and only have coins of the following types: 25 cents, 10 cents, 5 cents, and 1 cent. Write a Python function called currency (n) to calculate the minimum number of coins the cashier can donate, or n is a real (float). The function takes as input in parameter the value n in dollars. Use the following algorithm: multiply the dollar value with 100 to turn it into cents (pennies). Next, calculate the possible number of 25-cent coins. If there is a remainder, calculate the number of dimes, then 5 cents, and finally 1 cent, if necessary. The function should display the number of 25 cents, 10 cents, 5 cents, and 1 cent coins, as shown in the photo. And at the end the function should return the minimum total number of parts, which is an integer (int). Use modulo and integer division for calculations. Examples: - If the cashier has to return $ 0.56, the minimum number of coins is 4 (2 coins of 25 cents, 0 10 cents, 1 5 cents and 11 cent). It is not possible to give 3 pieces (or less) so the minimum number in this case is 4. - If the amount to be returned is $ 1.42, the minimum number of coins is 9 cents, 1 10-cent coin, 1 5-cent coin and 2 1-cent coins). coins of 25 >>>#test Q7 >>> numMonnaies (1.56) 6 pieces de 25 cents, 0 pieces de 10 cents, 1 pieces de 5 cents, 1 pieces de 1 cent 8 >>> numMonnaies (1.42) 5 pieces de 25 cents, 1 pieces de 10 cents, 1 pieces de 5 cents, 2 pieces de 1 cent 9. >>> numMonnaies (1) 4 pieces de 25 cents, 0 pieces de 10 cents, 0 pieces de 5 cents, 0 pieces de 1 cent 4
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education