Can you annotate and create a flowchart for this code. Provide description outlining which option chosen to write the code and a description of how it works and how to use it. Can you also check this code for syntax errors. I want it written in python.
Can you annotate and create a flowchart for this code.
Provide description outlining which option chosen to write the code and a description of how it works and how to use it.
Can you also check this code for syntax errors. I want it written in python.
flag = 0
while flag == 0 :
cost = float(input("Enter the cost: "))
amount = float(input("Enter the amount given(should be greater than cost): "))
if amount < cost :
print("Amount should be greater than cost.")
else:
flag = 1
change = amount-cost
print(f"The change to be given is ${change}")
twenty=0
ten=0
five=0
single=0
quarter=0
dime=0
nickel=0
penny=0
while change>=20 :
twenty+=1 #incrementing twenty until change is greater than or equal to 20
change-=20 #decrementing 20 from change
while change>=10 :
ten+=1#doing the above operation for all possible dollar bills
change-=10
while change>=5:
five+=1
change-=5
while change>=1:
single+=1
change-=1
while change>=0.25:
quarter+=1
change-=0.25
while change>=0.10:
dime+=1
change-=0.10
while change>=0.05:
nickel+=1
change-=0.05
while change>=0: #Checking with 0 to counter precision
penny+=1
change-=0.01
#Displaying the results
print(f"For that you require the following:")
print(f"Twenty dollar bills: {twenty}")
print(f"Ten dollar bills: {ten}")
print(f"Five dollar bills: {five}")
print(f"Single dollar bills: {single}")
print(f"Quarter dollar bills: {quarter}")
print(f"Dime dollar bills: {dime}")
print(f"Nickle dollar bills: {nickel}")
print(f"Penny dollar bills: {penny}")
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 6 steps with 7 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)