Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part III: 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 III: 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 ordering system for its customers. Each customer will type in a code representing the structure of his or her order, and your program will calculate the total cost of the order An order ode is define 1 as a case-sensitive) string of letters: each letter represents some element of the burger(the protein type, a topping, or a condiment). The valid codes for prolein types, toppings, and condirnents are as follows: Protein Toppings ($0.50 each) Condiments (free) Letter Putty Type Price $2.00 Turkey $2.30 $2.25 Letter Topping Letter Condiment 1Lettuce t Tomato o Onion B Beef Ketchup u Mustard y Mayonnaise a A.1. steak sauce Pickle d Jalapeo peppers c Cheese b Bacon s Sauted onions m Sauted mushrooms Barbecue sauce Fried onions For example, "Tpmlmy" represents a turkey burper with pckle, heavylextra sauted mushrooms, letuce, axl mayonnaise ($4.50), while "Bcbqa" represents a beef hamburger with cheese, bacon, and heavylextra barbecue sauce (33.00). Complete the burgerfunctn, which takes a single string parameter representing a customer order. 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 op is a good way to do this), keeping track of several values: The type of protein that has been odered The lotal 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 elements of an onler mav he arrain ed in any onler: rDr exame, oondiments and li "ngs may be m'oesl together, with the proem t al the end. Toppings and condiments may be repeated (idicating extra uantities of that topping or condimenrepeating a topping or condiment still counts tward the limit for that type of element, so 3 t' tomato")characters will only allow the customer to adkd up to 2 additional toppings (likewise, 2 oopies of a single condiment means that no additional condiments may be ordered) If the parameter string is a valid oner (exactly one pro ein 0-5 'ngs, and 0-2 condiments your function should return a lral repnesenting the lotal os o th onier:potein cost (0.5x mber_of toppings) (don't wrry i If th order is invalid because it contains too many protein types (or no protein type at all), or bocause it contains too If the parameter string contains an invalid character (e.g., anx', which 18 lkt present in any of the three tables above). Hint: You can simplify your classification tests by using the in opcrator with a single string that holds all the valid letters the oost doesn't have cxactly two digits after the decimal point) many toppings or condiments, your function should return the exact string "invalid onder" (all lowercase). ur function should mmertiaely lerminale an relrn the exact string "unrecognied oner coleall kwercase) for that catepory. For example, lattor in BTV will return Truo if the variable lotter matches any protein type

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

More Books

Students also viewed these Databases questions