Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

could you please help me to solve this question? the menu app Bad things to do (don't do bad things): use a code from a

could you please help me to solve this question?

the menu app

Bad things to do (don't do bad things):

use a code from a previous iteration of this course (results in no grade for this project)

post this project to the internet (results in failing the course)

Your goal is to write a code that mimics a menu app. How does a menu app work? A menu contains groups, for example: drinks, entrees, deserts, sides, etc. The menu app, asks the user if they want an item from one of the groups. If the response is yes, then the menu app displays the items in the group with prices and asks the user to make a selection. If the response is no, the menu app moves to the next group. At the end the menu app ask the user if they want to leave a tip. The user has a choice, either select from 15%, 20% and 25% or leave a custom tip. The menu app then applies the tip to the bill and displays the final ammount.

We will keep our menu app simple. The user can only order one or no items from a group.

**Here are some of the things you will need to know to complete this project: **

functions

conditionals

loops

lists

dictionaries

modular programing

One of the biggest mistakes students make is that their menu app only works for their menu. So, let me state this emphatically, your code should be able to work with all menus, not just your own, I will actually grade your code using my menu (no, you don't get to see my menu). No credit is given if your code does not work with my menu. A good way to test your code is to create two very different menus or borrow a classmates menu and see if your code works.

advice on how to proceed

you will need to practice reduction - reduce the project into simpler ideas and work those ideas out

you will not be able to finish this project in one or two or three or even four attempts, this project will take a considerable amount of time for some of you (10-20 hours or more). The due date is firm.

organization of code

You will have three files:

main.py, which contains the main code

menu_functions.py, which contains all the functions called from the main code

menu.py, which contains the menu data, this is the only place that has specific information about your menu

organization of the menu data

menu grouping data is contained in a list

the menu is contained in a dictionary

this data is contained in the file menu.py

Here is some example code

 

drinks=[["coffee", 1.00], ["chocolate milk", 2.00], ["orange juice", 3.00]]

breakfast=[["panckaes", 3.00], ["eggs and toast",2.00], ["oatmeal", 1.00], ["granola"], 1.50]]

sides=[["hashbrowns", 1.00], ["toast", .5], ["fruit",.75]]

# dictiionary containing each group

menu={}

menu["drinks"]=drinks

menu["breakfast"]=breakfast

menu["sides"]=sides

Notice (above code):

how the item name and price is organized in a list (must be this way)

each grouping is contained in a dictionary

the dictionary keys contain the names of the groups

Rules:

you must use your own menu, not the example given

you must have at least three groups

each group must have at least three items

the size of the groups can not all be the same

Looping through the dictionary keys:

you are going to need to loop through the dictionary keys

this way for each key you can aks the user if they want to order from a particular grouping

here is an example using the code from above

 

for key in menu.keys():

print(key)

# you could also try the code commented bellow

# phrase=f"Would you like to order a {key}?"

# print(phrase)

# prompt the user to enter yes or no

# if the user enters yes, go on to a function that

# displays he group items and asks the user to select an item

# if the user enters no, continue on to the next group

exercises to try to help move you along

Be sure you know how to inport .py files into one another (modular programing).

Write a function called select_item that has a single input, a list of items and prices as organized for this project (that is just one list - one of the groupings). The function displays the items and their price numbered 1 through the number of items. The function then prompts the user to input a selction by entering in a number 1 through the number of items. The function then returns the item name and price.

 

def select_item(items):

'''

items : a list containing names and prices for a particular menu group

returns: name and price of item selected

'''

As a customer selects items how would you collect the data for the item name and price? There are multiple things to collect, we need an Python object that can contain multiple things (like a bucket).

Write a function called add_tip that has a single paramter- the total amount for the bill. The function computes the tip amount for 15, 20, and 25 %. The function then gives the user 4 options to select from: 1 to leave 15 percent tip, 2 for a 20 percent tip, 3 for a 25 percent tip, and 4 for a custom amount. (Be sure your display displays the percent of tip and the amount.) If the user selects option 4 prompt the user to input the tip amount. The function then returns the tip ammount.

 

def add_tip(bill):

'''

bill : the bill before adding a tip

returns: the amount of tip that will be added to the bill

'''

To note:

if you code is long, then you are probably repeating code - it is getting redundant

work out a game plan first

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

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

More Books

Students also viewed these Databases questions

Question

What is Centrifugation?

Answered: 1 week ago

Question

To find integral of ?a 2 - x 2

Answered: 1 week ago

Question

To find integral of e 3x sin4x

Answered: 1 week ago

Question

To find the integral of 3x/(x - 1)(x - 2)(x - 3)

Answered: 1 week ago

Question

What are Fatty acids?

Answered: 1 week ago

Question

=+Are the contracts enforceable?

Answered: 1 week ago