Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 3: Identify & Fix the Error Analyze the code to your left. It contains three errors. Identify this type of error and fix the

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Exercise 3: Identify \& Fix the Error Analyze the code to your left. It contains three errors. Identify this type of error and fix the code. When running correctly, the program will determine the price for each doughnut based on the quantity they want to buy. Once a price has been deteremined the program will calculate the subtotal, tax and total for the order. If the user enters 6 for the number of doughnuts, the program should print: Subtotal: $9.0 Tax: $0.54 Total: \$9.54 Fdeclare variables num_doughnuts = int ( ) price=float () subtotal=float ( ) tax float ( ) total=float ( ) HAsk user for the number of num doughnuts num_doughnuts-int (input ( "Enter the number of doughnuts:")) \#Determine price for each doughnut if num doughnuts c=6 : price 1.5 elif num_doughnuts =8 : "First error, we have to use "elif" not "if". This is a senantic error (Logical error) price=1.250 elif num_doughnuts =12 : "Second error, we have to use "elif" again not "if". This is a semantic error price =1.15 else: price =1.00 FDetermine the tax, subtotal and subtotal subtotal=num_doughnuts*price tax=subtotal total=subtotalttax; FThird error, we have add subtotal and tax to get total. This is a semantic error Hprint out subtotal, tax and total print ( "Subtotal: \$". num_doughnuts*price) print ("Tax: $ ", tax) print ( "Total: \( \$ " \)quot;, total) To tect your code pror to uradina cick on the Code Yisuabier button. When you fawn foed the code cliken the Chinckit butron Cudio will run. wourarpgram twice. The firyt teit will une of for the number of dooghingts The swoond test witt use another type of lnout File "contentejerrera-p9. tine 12 isdentaktonifrert unewpected inbert. Flide -content/errora-py", Line 12 elif ram_dougherte enas: Indevestionifrors unespected tradent. file "content/errera. Fy, the in olit menidnogherts ene: Syntaverrore ieval ld syntax Check 1 failed Output: File "Content/error3.py", line 12 elif num_doughnuts =8 : Syntaxerror: invalid syntax Expected: Enter the number of doughnuts: Subtotal: $9.0 Tax: $0.54 Total: $9.54 Feedback: Make sure you have identified all 3 errors. Check 2 failed Output: File "Content/error3.py", line 12 elif num_doughnuts

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

Spatio Temporal Database Management International Workshop Stdbm 99 Edinburgh Scotland September 10 11 1999 Proceedings Lncs 1678

Authors: Michael H. Bohlen ,Christian S. Jensen ,Michel O. Scholl

1999th Edition

3540664017, 978-3540664017

More Books

Students also viewed these Databases questions

Question

What do you think has caused the failures?

Answered: 1 week ago

Question

Prepare for a successful job interview.

Answered: 1 week ago

Question

Describe barriers to effective listening.

Answered: 1 week ago

Question

List the guidelines for effective listening.

Answered: 1 week ago