Answer:
The following program is written in python programming language:
amount = int(input("Enter Amount: "))
#Check if the input is less than 1
if amount<=0:
print("No Change")
else: #If input is valid
#Convert input into different coins
dollar = int(amount/100) #Dollar conversion
amount = amount % 100 #Calculate remainder
quarter = int(amount/25) #Quarter conversion
amount = amount % 25 #Calculate remainder
dime = int(amount/10) #Dime conversion
amount = amount % 10 #Calculate remainder
nickel = int(amount/5) #Nickel conversion
penny = amount % 5 #Calculate remainder
#Display 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:
The program is implemented using python and includes comments for clarification.
The variable amount is defined as an integer.
The check in line 3 determines if the amount is less than or equal to 0.
If it is, "No Change" is printed.
If not, it converts the entered amount into smaller coins.
Line 7 converts the input amount to its dollar counterpart.
Line 8 calculates the remainder.
Line 9 converts the remainder to quarters.
Line 10 calculates the new remainder.
Line 11 converts the current remainder to dimes.
Line 12 calculates the adjusted remainder.
Line 13 calculates the nickel equivalent.
Line 14 gets the penny equivalent of what's left.
Lines 16 and beyond display the result using the correct terminology (singular or plural).