Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I cannot figure out why my code doesn't return anything, so I started indenting more and I think I messed it up worse. Can someone

I cannot figure out why my code doesn't return anything, so I started indenting more and I think I messed it up worse. Can someone help me sort this?

SCENARIO:

Havea 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 

MY CODE:

def changeFunction(amount):

if amount >= 100:

dollars = amount//100

if dollars > 1:

print(dollars, ' Dollars')

else:

print(dollars, ' Dollar')

elif amount >= 25:

quarters = amount // 25

if quarters > 1:

print(quarters, ' Quarters')

else:

print(quarters, ' Quarter')

elif amount >= 10:

dimes = amount // 10

if dimes > 1:

print(dimes, ' Dimes')

else:

print(dimes, ' Dime')

elif amount >= 5:

nickels = amount // 5

if nickels > 1:

print(nickels, ' Nickels')

else:

print(nickels, ' Nickel')

elif amount >=1:

pennies = amount // 1

if pennies > 1:

print(pennies, ' Pennies')

else:

print(pennies, ' Penny')

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

Explain why interpersonal skills are vital in healthcare management

Answered: 1 week ago