Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python Program Functional Specifications: 1. The program will prompt the user for various pieces of information about the desired breakfast. The required information is described

Python Program

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Functional Specifications: 1. The program will prompt the user for various pieces of information about the desired breakfast. The required information is described below. Some of the information is dependent on the type of breakfast being ordered. Once all the information has been entered, the program will compute and display the amount of money (including tax) charged for the customer's breakfast. 2. The customer can build a custom breakfast from the following individual food and beverage items: egg ($0.99 each), bacon ($0.49 per strip), sausage ($1.49 each), hash brown ($1.19 each), toast ($0.79 per slice), coffee ($1.09 per cup), and tea ($0.89 per tea bag). For example, the customer can order two eggs with two toasts and a cup of coffee. 3. The program will display the available choices in the following way: Enter item (a to terminate): egg, bacon, sausage, hash brown, toast, coffee, tea: and the user will type the customer's choice. For instance, if the customer wants an egg, the user will type: egg . The program will then ask for the quantity (how many egg). The program continues to ask for additional menu items by re-displaying the choices. When the customer is done ordering, the user enters q, the program then displays the pre-tax total, the tax, and the total with tax. Other scenarios are possible, in which the customer decides to customize the breakfast order. 4. One way to keep the program running until user manually input q is to use a while loop: complete = False; while not complete: item = input ("Enter item (a to terminate): egg, bacon, sausage, hash brown, toast, coffee, tea:") if item in {"egg", "bacon", "sausage", "hash brown", "toast", "coffee", "tea", "q"}: if item == "q": complete = True if not complete: # you code should be there else: print("") # some error messages. 5. The program will compute the total cost of the order with additional taxes of 13%. All the costs are to be rounded to the nearest penny, and displayed with a dollar sign and two decimal positions. For example, a total cost of 13.66666 will be displayed as $13.67 6. The program must request user input in the same order as per the example runs below. That is to say, the program will ask for the menu item and then for its quantity, not the other way around. 7. Your program must accept inputs whether they contain upper-case or lower-case characters (for example, TeA and Bacon should both be accepted). Additionally, your program must be robust to leading and trailing spaces, including cases when multiple spaces separate words in input lines, for example("hash brown and hash brown)A Python function that performs this type of input formatting is provided to you: def formatInput (textLine) : textLine = textLine.lower().strip () wordList = textLine.split() textLine = "".join(wordList) return textLine 8. The program must also detect and report invalid input; that is, the input must match one of the keywords or phrases exactly (ignoring upper case and spaces). When an invalid input is detected, the program will display an error message, and prompt for the input until the user enters it correctly. 9. Finally, your program must be robust to users entering input other than numbers when quantities are requested. That is, you should input the string and validate that the input is numeric. This can be done using isnumeric(). So to test whether the value of a variable quantity is actually a number you can do quantity.isnumeric(). This will return True if it is a number and False otherwise

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

Students also viewed these Databases questions