PYTHON HELP Write a Python program that will input a monetar

PYTHON HELP

Write a Python program that will input a monetary (dollar) value and determine the minimum number of coins (quarters, dimes, nickels and pennies) whose total equals the entered value. For those of you who are unfamiliar with U.S. currency, 1 dollar equals 100 cents. A quarter is worth 25 cents, a dime is worth 10 cents, a nickel is worth 5 cents and a penny is worth 1 cent. Your program must input two integer values representing the dollars and cents, respectively, and then determine and output the minimum number of quarters, dimes, nickels and pennies whose total equals the entered value.

• Use only mathematical operations (no conditional operators)

• Do not import or use any module functions

Solution

dollor = int(input(\"Enter the dollor value: \"))
quarter = int(dollor / 25)
dollor = dollor % 25
dime = int(dollor / 10)
dollor = dollor % 10
nickel = int(dollor / 5)
dollor = dollor % 5
penny = dollor

print(\"minimum number of quarters: \"+str(quarter))
print(\"minimum number of dime: \"+str(dime))
print(\"minimum number of nickel: \"+str(nickel))
print(\"minimum number of penny : \"+str(penny ))

Output:

sh-4.3$ python3 main.py                                                                                                                                                                                                                                 

Enter the dollor value: 99                                                                                                                                                                                                                              

minimum number of quarters: 3                                                                                                                                                                                                                           

minimum number of dime: 2                                                                                                                                                                                                                               

minimum number of nickel: 0                                                                                                                                                                                                                             

minimum number of penny : 4                                                                                                                                                                                                                             

sh-4.3$ python3 main.py                                                                                                                                                                                                                                 

Enter the dollor value: 73                                                                                                                                                                                                                              

minimum number of quarters: 2                                                                                                                                                                                                                           

minimum number of dime: 2                                                                                                                                                                                                                               

minimum number of nickel: 0                                                                                                                                                                                                                             

minimum number of penny : 3                                                                                                                                                                                                                             

sh-4.3$ python3 main.py                                                                                                                                                                                                                                 

Enter the dollor value: 69                                                                                                                                                                                                                              

minimum number of quarters: 2                                                                                                                                                                                                                           

minimum number of dime: 1                                                                                                                                                                                                                               

minimum number of nickel: 1                                                                                                                                                                                                                             

minimum number of penny : 4

PYTHON HELP Write a Python program that will input a monetary (dollar) value and determine the minimum number of coins (quarters, dimes, nickels and pennies) wh
PYTHON HELP Write a Python program that will input a monetary (dollar) value and determine the minimum number of coins (quarters, dimes, nickels and pennies) wh

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site