Write a Fast Food program in Python that uses functions to d

Write a Fast Food program in Python that uses functions to display a menu of items to the user,

takes the order, and calculates the total.

The user selects which item they would like and how many of that item they would

like.

The user continues to enter items until they are finished. Once they have signified that

they are done, calculate the total cost and display it to the user along with the total

number of items.

Write the following functions

:

1.

Display the menu option

s

you can use the example below, or make up your

own items and prices. Have at least three items to sell.

2.

Check

the user’s

menu

input to make sure that

what they enter is valid (ie. an

integer within the menu’s range

).

3.

Check the user’s quantity input to

make sure that what they enter is valid (ie. a

positive integer).

4.

Pass in the price of the item and the quantity, return the cost for those items.

5.

Pass in the cost for those items and the subtotal so far, add the cost to the

subtotal, then return the new

subtotal.

6.

Pass in the subtotal, compute the price of tax and return it. Tax for this

restaurant is 9%.

7.

Pass in the subtotal, tax, and total number of items. Calculate the final total,

and then display the subtotal, tax, and final total, all with decimal

formatting.

Example Output:

MacDoogle’s:

1. Hamburger =

$1.50

2. Soda =

$1.15

3. Fries =

$1.25

4. Complete Order

1

Enter Number of Hamburgers: 2

MacDoogle’s:

1. Hamburger =

$1.50

2. Soda =

$1.15

3. Fries =

$1.25

4. Complete Order

1

Enter Number of Hamburgers: 2

MacDoogle’s:

1. Hamburger =

$1.50

2. Soda =

$1.15

3. Fries =

$1.25

4. Complete Order

2

Enter Number of Sodas: 1

MacDoogle’s:

1. Hamburger =

$1.50

2. Soda =

$1.15

3. Fries =

$1.25

4. Complete Order

4

Su

btotal:

$4.15

Tax:

$0.37

Total Cost: $4.52

Number

of items: 3

Enjoy Your Meal!

Solution

price = [5.0, 6.5, 4.5 ] item_name = [\"Coffee Time\", \"Burger\", \"Pizza\" ] def display(): i = 1; for item in item_name: print str(i) + \" \" + item + \" = \" + str(price[i - 1]) i += 1 print str(i) + \" Complete Order.\" def check(inp): if inp < 1: print \"Item number should not be less than 1.\" return False; if len(item_name)+1 < inp: print \"Item number out of range.\" return False; return True; def check_quantity(inp): if inp < 1: print \"Quantity should not be less than 1.\" return False; return True; def calculate_cost(item, quantity): return price[item - 1] * quantity def subtotal(cost, sub): return sub + cost def calculate_tax(sub): return sub * 9.0 / 100.0 def print_output(sub, tax, num_item): print \"Sub total: $\" + str(sub) print \"Tax: $\" + str(tax) print \"Total: $\"+str(sub+tax) print \"Number of item: \" + str(num_item) num = 0 sub = 0.0 while True: display() i = int(raw_input(\"\")) if check(i): if (i == len(item_name) + 1): print_output(sub, calculate_tax(sub), num) break print \"Enter number of \" + item_name[i - 1] + \" :\" quan = int(raw_input()) if (check_quantity(quan)): sub = subtotal(calculate_cost(i, quan), sub) num += quan
Write a Fast Food program in Python that uses functions to display a menu of items to the user, takes the order, and calculates the total. The user selects whic
Write a Fast Food program in Python that uses functions to display a menu of items to the user, takes the order, and calculates the total. The user selects whic
Write a Fast Food program in Python that uses functions to display a menu of items to the user, takes the order, and calculates the total. The user selects whic

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site