Write a program with total change amount as an integer input, and
output the change using the fewest coins, one coin type per line. The coin types are Dollars, Quarters, Dimes, Nickels, and Pennies. Use singular and plural coin names as appropriate, like 1 Penny vs. 2 Pennies.
Ex: If the input is:
0
(or less than 0), the output is:
No change
Ex: If the input is:
45
the output is:
1 Quarter
2 Dimes

Respuesta :

Answer:

amount = int(input())

#Check if input is less than 1

if amount<=0:

    print("No change")

else: #If otherwise

    #Convert amount to various coins

    dollar = int(amount/100) #Convert to dollar

    amount = amount % 100 #Get remainder after conversion

    quarter = int(amount/25) #Convert to quarters

    amount = amount % 25 #Get remainder after conversion

    dime = int(amount/10) #Convert to dimes

    amount = amount % 10 #Get remainder after conversion

    nickel = int(amount/5) #Convert to nickel

    penny = amount % 5 #Get remainder after conversion

    #Print results

    if dollar >= 1:

          if dollar == 1:

                print(str(dollar)+" Dollar")

          else:

                print(str(dollar)+" Dollars")

    if quarter >= 1:

          if quarter == 1:

                print(str(quarter)+" Quarter")

          else:

                print(str(quarter)+" Quarters")

    if dime >= 1:

          if dime == 1:

                print(str(dime)+" Dime")

          else:

                print(str(dime)+" Dimes")

    if nickel >= 1:

          if nickel == 1:

                print(str(nickel)+" Nickel")

          else:

                print(str(nickel)+" Nickels")

    if penny >= 1:

          if penny == 1:

                print(str(penny)+" Penny")

          else:

                print(str(penny)+" Pennies")

Explanation:

ACCESS MORE
ACCESS MORE
ACCESS MORE
ACCESS MORE