Question: I need help with the following Python 3 question: Write a Python program that, for a given amount of money (given as a float), breaks

I need help with the following Python 3 question:

Write a Python program that, for a given amount of money (given as a float), breaks the amount down into different denominations. Report the output in terms of:

Number of dollars Number of quarters Number of dimes Number of nickels Number of pennies

Your program must report these outputs using the minimum number of coins/dollars possible. This is called an optimization problem. We could turn the amount into all pennies, and thats technically correct -- it converts an amount into a breakdown of denominations. But, its not what were going for here; instead, we want a correct solution, with the fewest coins/dollars we can possibly come up with. The input from the user is a float. If they enter more than two digits after the decimal place, round to the closest 100th.

Test case #1: $4.50 4 dollars, 2 quarters, 0 dimes, 0 nickels, 0 pennies

Test case #2: $.2879 0 dollars, 1 quarter, 0 dimes, 0 nickels, 4 pennies

Other notes:

Any value used more than once is saved in a variable, not used as a literal

Use only one print statement for the final output, but without going over 80 column-width in the Python code.

Example Output:

Enter the change amount

3.7812

The breaks down to:

3 dollars

3 quarters

0 dimes

0 nickels

3 pennies

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 Databases Questions!