Pleaser fix the code below:   Since functions should do a single logical task, there is no need for the userInputCalc function to collect the info and also do the summary calculations, so move line 61 to line 72. Then, place line 67-72 inside a main() function, and place a call to this function at the end of the program file. Also, fix the names of the menu items (in menu_items) with spaces so they all have the same size. also, there is a simpler way: change {:<15} with {:<20} in lines 22 and 25. Also, use format for the “Subtotal” and “Grand total” (just like you did for “Sales tax” and “Suggested tip”) Also, the $ should go in front of the

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Pleaser fix the code below:

 

Since functions should do a single logical task, there is no need for the userInputCalc function to collect the info and also do the summary calculations, so move line 61 to line 72. Then, place line 67-72 inside a main() function, and place a call to this function at the end of the program file.

Also, fix the names of the menu items (in menu_items) with spaces so they all have the same size.

also, there is a simpler way: change {:<15} with {:<20} in lines 22 and 25. Also, use format for the “Subtotal” and “Grand total” (just like you did for “Sales tax” and “Suggested tip”)

Also, the $ should go in front of the each amount.

 

PLEASE MAKE THOSE CHANGES IN THE CODE BELOW:

 

 



Summary
This program will create a new version of the restaurant ordering program
that uses lists to look up menu items, record the items ordered by the user,
and print a full receipt.
'''


def Menu(menu_items,menu_prices):
print("Menu Card")
count = 1
for i,j in zip(menu_items,menu_prices):
print("{}. {} price is {:.2f}$".format(count,i,j))
count+=1

def printReceipt(ordered_items,ordered_quantity,menu_prices,menu_items):
subtotal = 0
print("{:<15} {:<10} {:<7} {:<7}".format("Items","Quantity","Rate","Total"))
for i,j in zip(ordered_items,ordered_quantity):
subtotal += j*(menu_prices[i])
print("{:<15} {:<10} {:5.2f} {:5.2f}".format(menu_items[i],j,menu_prices[i],j*menu_prices[i]))





tax = 0.085*subtotal
tip = 0.15*subtotal
grand = subtotal+tax+tip
print("\n------Reciept------")
print("\nSubtotal: ",subtotal,"$")
print("Sales tax : {:.2f}$".format(tax))
print("Grand total : ",grand,"$")
print("Suggested tip : {:.2f}$".format(tip))


def userInputCalc(menu_items,menu_prics,ordered_items,ordered_quantity):
continueLoop = 'y'
while continueLoop=='y':
Menu(menu_items,menu_prices)
DishNumber = int(input("\nEnter numbers between 1 and 10:"))
if DishNumber<1 or DishNumber>10:
print("Invalid Input")
continue

print("{} is {}$".format(menu_items[DishNumber-1],menu_prices[DishNumber-1]))
quantity = int(input("Enter Quantity: "))
if quantity < 1:
print("Invalid Input")
continue

ordered_items.append(DishNumber-1)
ordered_quantity.append(quantity)

continueLoop = input("\nEnter y to Continue or n to quit:")

printReceipt(ordered_items,ordered_quantity,menu_prices,menu_items)

 

 

menu_items = ["Cajun Calamari","Shrimp Cocktail","Spicy Garlic Mussels","Crispy Ahi","Spinach Artichoke","Steamed Clams","Chips and Dip","Beer Battered Ribs",
"St.Louis Ribs","Mozzarella Sticks"]
menu_prices = [9,9,9,10.5,8,10,6.5,6,8,7]
ordered_items = []
ordered_quantity = []


userInputCalc(menu_items,menu_prices,ordered_items,ordered_quantity)

 

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education