Question

1. Find and name [syntax, runtime, semantic) all FIFTEEN Errors. (15 pts - finding, 15 pts - labeling) If more than 15 errors

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Syntax Error 1 Line 19 :  total_fruit = fruits * $0.50 # it should be total_fruit = fruits *  0.50

Syntax Error 2 Line 20: total_veg = veggies * $0.25 # it should be total_veg = veggies * 0.25

Syntax Error 3 Line 20:  total_meat = meat * $2.50 # It should be total_meat = meat * 2.50

Logic Error 4 Line 27: if discount_check == 50: # it should be if discount_check > 50

Logic Error 5, 6 Line 31: if discount >= 40: # it should be elif discount_check >= 41

Logic Error 7 Line 32: total_cost += total_cost *.20 # it should be  total_cost -= total_cost *.20

Logic Error 8 Line 35: if discount_check >= 30: # it should be elif discount_check >= 30

Logic Error 9 Line 36: total -= total *.10 # it should be  total_cost -= total_cost *.10

Logic Error 10 Line 39, 40: else: return total_cost # There is no need for else condition here. It just needs to return total_cost

Code without errors:

def grocery_checkout(fruits, veggies, meat):

    total_fruit = fruits * 0.50

    total_veg = veggies * 0.25

    total_meat = meat * 2.50

    total_cost = total_fruit + total_veg + total_meat

    discount_check = fruits+ veggies + meat

    if discount_check > 50:

        total_cost -= total_cost * 0.20

        print("20% discount!")

    elif discount_check >= 41:

        total_cost -= total_cost * 0.15

        print("15% discount!")

    elif discount_check >= 30:

        total_cost -= total_cost * 0.10

        print("10% discount!")

    return total_cost

#Main method to test the grocery checkout method with user inputs

fruits = int(input('Enter number of Fruits: '))

veggies = int(input('Enter number of Veggies: '))

meat = int(input('Enter number of pounds of Meat: '))

print('Total Cost: ',grocery_checkout(fruits, veggies, meat),'$')

Code screenshot:

2 i def grocery_checkout (fruits, veggies, meat): total fruit = fruits * 0.50 3 total_veg = veggies * 0.25 4 total meat = mea

outputs:

RESTART: C:\Users\devak\AppData\Local Enter number of Fruits: 10 Enter number of Veggies: 10 Enter number of pounds of Meat:

Add a comment
Know the answer?
Add Answer to:
1. Find and name [syntax, runtime, semantic) all FIFTEEN Errors. (15 pts - finding, 15 pts...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Use java and continue stage 2 and 3 stage 1 code public abstract class BabyItem { protected String name;...

    Use java and continue stage 2 and 3 stage 1 code public abstract class BabyItem { protected String name; public BabyItem() { name=""; } public BabyItem(String name) { this.name = name; } public String getName() { return name; } public void setName(String name) { } public abstract double getCost(); } ======================================================================================== public class BabyFood extends BabyItem { private int numberOfJars; private double pricePerDozen; public BabyFood() { super(); numberOfJars = 0; pricePerDozen = 0; } public BabyFood(int numberOfJars, double pricePerDozen) {...

  • Write a code using loop and flag function in python jupitior notebook: Ask the user for...

    Write a code using loop and flag function in python jupitior notebook: Ask the user for the number of items they bought. Also ask the price of each item they bought and quantity purchased. Display the total amount they owe. Ask the user for a number n. Calculate 1+2+3+….+n. Ask the user for a number n. Calculate 1*2*3*…*n. Ask the user for number of rows (r) and columns (c). Print * for r rows and c columns. Ask the user...

  • answer all numbers and show work please the next pictures are the lessons guide Find the...

    answer all numbers and show work please the next pictures are the lessons guide Find the commissions on the following sales using the given rates. 3. $5764 at 20% 5. $12,356 at 12% 4. $2598 at 15.5% 6. $3456 at 9% Find the following piecework earnings. 7. 2010 pieces at $0.18 per piece 9. 52 pieces at $3.25 per piece 8. 264 pieces at $1.50 per piece 10. 197 pieces at $1.67 per piece Find the total tips for the...

  • QUESTION 1 Customers arrive at a hair salon according to a Poisson process with an average of 1...

    QUESTION 1 Customers arrive at a hair salon according to a Poisson process with an average of 16 customers per hour. Which of the following is most likely true, based on this information: a. The hair salon serves customers on a walk-in basis (rather than by appointment times) b. If 10 customers arrive in the first hour, it is likely that 22 customers will arrive in the next hour. c. If the salon can serve an average of 20 customers...

  • Please help, need to code for this business assignment using c++. Business Expense Reimbursements Calculator Probl...

    Please help, need to code for this business assignment using c++. Business Expense Reimbursements Calculator Problem statement: Business trip is part of the enterprise culture. Suppose a businessperson just completed a business trip for your company. Now, you are tasked to write a program that calculates and displays the total travel expenses, allowable expenses for the trip, and the excess that must be paid by the businessperson, if any The program should prompt the user for the following . The...

  • Margin Analysis & Cannibalization for a college class Raul Ortega has just inherited "Ortega's Stop and...

    Margin Analysis & Cannibalization for a college class Raul Ortega has just inherited "Ortega's Stop and Shop," a small convenience store on the south side of Chicago. The store is small, even by convenience store standards, with an interior of 15' wide and 30 deep (plus a small amount of storage space in the back). Raul inherited the store from Uncle Jose, who passed away unexpectedly and did not have any children. Since Raul was his favorite nephew, Jose re-...

  • Need help with C++ assignment Assignment 1 and .txt files are provided at the bottom. PART...

    Need help with C++ assignment Assignment 1 and .txt files are provided at the bottom. PART A PART B Assignment 1 #include <iostream> #include <string> #include <fstream> #include <iomanip> #include <stdio.h> #include <ctype.h> #include <string.h> #include <algorithm> using namespace std; /** This structure is to store the date and it has three integer fields **/ struct Date{    int day;    int month;    int year; }; /** This structure is to store the size of the box and it...

  • Please use the above info to answer the next problems B C D 1 Due to...

    Please use the above info to answer the next problems B C D 1 Due to its popularity, the Black and White Handbag (BW14293) is normally a stock item. However, the 2 handbag is currently out of stock. Rather than producing only enough units to fill Katie's order, 3 management would like to produce a job (Job 114) that is large enough to fill Katie's order and replenish 4 stock. The fabric used for this job can be stacked four...

  • Additional code needed: PartA: BurgerOrder class (1 point) Objective: Create a new class that represents an...

    Additional code needed: PartA: BurgerOrder class (1 point) Objective: Create a new class that represents an order at a fast-food burger joint. This class will be used in Part B, when we work with a list of orders. As vou work through this part and Part B, draw a UML diagram of each class in using the UML drawing tool 1) Create a new Lab5TestProject project in Netbeans, right-click on the lab5testproject package and select New>Java Class 2) Call your...

  • In Diet & Wellness Plus you will create the below profile and add the foods below....

    In Diet & Wellness Plus you will create the below profile and add the foods below. You will then pull Reports and answer the questions. Topic: Dietary Reference Intakes (DRIs) Menu: Sample 2,000 calorie menu (from MyPlate) DWP Reports Used Intake vs. Goals MyPlate Analysis Go to Diet & Wellness Plus and create the following profile for Reuben Ward. Birth Date: May 7, 1998 (Note: adjust the date of birth on this assignment so that Reuben is 19 years old...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT