Computer Networking: A Top-Down Approach (7th Edition)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
Bartleby Related Questions Icon

Related questions

Question

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}")

Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Similar questions
Recommended textbooks for you
Text book image
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Text book image
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Text book image
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Text book image
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Text book image
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Text book image
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY