Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Part II: Building Burgers (6 points) Place your answer to this problem in the burger.py file) Burgers To-Go has hired you to develop a new

image text in transcribed
Part II: Building Burgers (6 points) Place your answer to this problem in the burger.py file) Burgers To-Go has hired you to develop a new food ordernng system for its customers Each customer will type in a code representing the structure of his or her order, and your program will calcul ate the total cost of the order. An order code is defined as a (case-sensitive) string of letters; each letter represents some clement of the burger the protein type, a topping, or a condiment). The valid codes for protein types, toppings, and condiments are as follows: Protein Toppings ($0.50 each) Condiments (free Letter Topping Letter Patty Type Price $2.00 T Turkey $2.50 V Veggie 2.25 Letter Condiment B Beef 1 Lettuce t Tomato o Onion P Pickle k Ketchup Mustard y Mayonnaise a A.1, steak sauce qBarbecue sauce Jalapeio peppars c Cheese b Bacon Saited onions m Sauted mushroom f Fried onions For ex ample, "Tpmlmy represents a turkey burger with pickle, heavylextra sauted mushrooms, lettuce, and mayonnaise ($4.50), while "Bcbq" represents a beef hamburger with cheese, bacon, and heavylextra barbecue sauce (S3.00) Complete the burger() function, which takes a single stnng paramet representing a cust nna orda. This function returns cither a number or a string, depending on the contents of its parameter. Your function should process its parameter one character at a time (a for loop is a good way to do this), keeping track of several values The type of protein that has been ondared The total number of toppings that have been ordered The total number of condiments that have been ordered A valid order MUST include exactly one protein, plus up to five toppings and up to two condiments. The dements of an order may be arranged in any order: for example, condiments and tppngs may be mixed together, with the protein type the end. Toppings and condiments may be sepeated (indicating extra quantities of that topping or condiment): repeating a topping or condiment still counts toward the limit for that type of element, so 3't' Ciomato) characters will only allow the customer to add up to 2 additional toppings (likewise, 2 copies of a single condiment means that no additional condiments may be ordered). - If the parameter string is a valid order (exactly one protein, 0-5 toppings, and 0-2 condiments), your function should retum a float representing the total cost of the order: prote in cost + (0.5 x ber of toppings) (don't worry if If the order is invalid because it contains too many protein types for no protein type at all), or because it contains too - If the parameter string contains an invalid character le.g.. an x. which is not present in any of the three tables above), Hint: You can simplify your dlassification tests by using the in operator with a single string that holds all the valid letters the cost doesn't have exactly two digits after the decimal point many toppings or condiments, your function should return the exact string "invalid order" (all lowercase) your function should immediatdly teminate and return the exact string "unrecognized order code" (all lowercase). for that catcgory. For cxample, letter in BTV will return True if the variable 1etter mtches any protcin typoc

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions