Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am a software engineering student studying python right now. We have to make a POS system (very simplistic) where the end user is asked

I am a software engineering student studying python right now. We have to make a POS system (very simplistic) where the end user is asked to input if the customer wants a table, if 'y' the end user should be prompted to enter table number and number of diners. Then for each diner it should display the menu of food and ask the end user if they want to order an item. If the answer is 'y' it should ask them for the number of the menu item, it should then take that menu item number and add the price of the menu item to a variable called total_price. it should do this until the response is 'n' then it should return the total price of all items choosen. It should repeat this for the amount of diners at the table. Once that is complete it should calculate the table total after tax and then it should calculate and display the tip amounts. The end user is then prompted to enter the tip amount and it should return the grand total. If the user answered 'n' when first asked if they want a table it should return the grand total for the day.

here is the code I have written so far: (the get_diner_order function is not responding correctly when 'n' is selected and it is not totaling the cost of all the items) please help!

# Develop a program that acts as a point of sale interface for a small restaurant.

eggs = '1) eggs $3.25' bacon = '2) bacon $4.00' pancakes = '3) pancakes $2.50' orange_juice = '4) orange juice $1.25' oatmeal = '5) oatmeal $3.99' milk = '6) milk $1.25' donut = '7) donut $2.00'

def get_a_table(): table = input('Do you want a table? Answer (y) ') if table == 'y': return table else: total_cost = display_table_total_info() return total_cost

def order_an_item(): order = input('Do you want to order an item? Answer (y or n) ') return order

def get_table_number(): table_number = int(input('Enter a table number: ')) return table_number

def get_number_of_diners_at_table(): number_of_diners = int(input('How many diners are at this table (1-4) ')) return number_of_diners

def display_menu_of_food_items(): print(eggs) print(bacon) print(pancakes) print(orange_juice) print(oatmeal) print(milk) print(donut) def get_menu_item(): menu_item = int(input('Enter the menu item number: ')) return menu_item

def get_diner_order(): total_cost = float(0.0) if order_an_item() == 'n': return (total_cost) else: response = get_menu_item() if response == int(1): price = float(3.25) total_cost = total_cost + price elif response == int(2): price = float(4.00) total_cost = total_cost + price elif response == int(3): price = float(2.50) total_cost = total_cost + price elif response == int(4) or int(6): price = float(1.25) total_cost = total_cost + price elif response == int(5): price = float(3.99) total_cost = total_cost + price else: price = float(2.00) total_cost = total_cost + price total_cost = total_cost + price get_diner_order() def calculate_table_total(): table_cost = get_diner_order() total_cost_with_tax = round(float(table_cost * float(.08)),2) return total_cost_with_tax

def display_diners_totals(): table_cost = get_diner_order() table_total = calculate_table_total() print('Total table cost before tax is {}'.format(table_cost)) print('Total table cost after tax is {}'.format(table_total))

def display_table_total_info(): table_total = calculate_table_total() ten_percent = round(float(table_total * .10),2) fifteen_percent = round(float(table_total * .15),2) twenty_percent = round(float(table_total * .20),2) twenty_five_percent = round(float(table_total * .25),2) print('10% tip: ' + str(ten_percent)) print('15% tip: ' + str(fifteen_percent)) print('20% tip: ' + str(twenty_percent)) print('25% tip: ' + str(twenty_five_percent)) tip_amount = float(input('Enter a tip amount: ')) grand_total = round(float(table_total + tip_amount),2) print('The grand total for the table is: $' + str(grand_total)) return grand_total

def get_table_order(): if get_a_table() == 'y': get_table_number() number_of_diners = get_number_of_diners_at_table() diners = 0 while diners

get_table_order()

Output from computer. See black box for where issues arise.

1. after selecting no, it should get the total from the 3 menu items listed before and do the 'Total table cost before/after tax' part of the code with the price of the 3 items before and after tax.

2. this example only had 1 diner but if there were others after the n it should present the menu list and ask what the next person wants and add those items to the total as well until the last person says 'n'

3. it should not ask 'do you want to order an item' after calculating the before and after tax price

image text in transcribed

Do you want a table? Answer (y) y Enter a table number: 6 How many diners are at this table (1-4) 1 1) eggs $3.25 2) bacon $4.ee 3) pancakes $2.50 4) orange juice $1.25 5) oatmeal $3.99 6) milk $1.25 7) donut $2.ee Do you want to order an item? Answer (y or n) y Enter the menu item number: 1 Do you want to order an item? Answer (y or n) y Enter the menu item number: 3 Do you want to order an item? Answer (y or n) y Enter the menu item number: 2 Do you want to order an item? Answer (y or n) n Do you want to order an item? Answer (y or n) n Do you want to order an item? Answer (y or n) n Do you want to order an item? Answer (y or n) n Do you want to order an item? Answer (y or n) n po you want to order an item? Answer (y or n) n Do you want to order an item? Answer (y or n) n Total table cost before tax is 0.0 Total table cost after tax is 0.0 po you want to order an item? Answer (y or n) n Tex tip: . 15% tip: @.@ 20% tip: 2.0 25% tip: @.@ Enter a tip amount: 2.2 The grand total for the table is: $e.e e.e None e.e Run Complete

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

Database Internals A Deep Dive Into How Distributed Data Systems Work

Authors: Alex Petrov

1st Edition

1492040347, 978-1492040347

Students also viewed these Databases questions

Question

2. Do the same for your favorite female film character.

Answered: 1 week ago