Question

IN PYTHON Menu: 1. Hotdog. ($2) 2. Salad ($3)  3. Pizza ($2) 4.Burger ($4) 5.Pasta ($7) Write...

IN PYTHON

Menu:

1. Hotdog. ($2) 2. Salad ($3)  3. Pizza ($2) 4.Burger ($4) 5.Pasta ($7)

Write a menu-driven program for  Food Court. (You need to use functions!)

  • Display the food menu to a user . 5 options
  • Use numbers for the options and for example "6" to exit.
  • Ask the user what he/she wants and how many of it. (Check the user inputs) AND use strip() function to strip your inputs(if needed)
  • Keep asking the user until he/she chooses the exit option.

(You can pass quantity1, quantity2, quantity3, quantity4 & quantity5 to save the quantities of the orders)

  • Calculate the price.
  • Ask the user whether he/she is a student or a staff. There is no tax for students and 9% tax for staffs. Add the tax price to the total price.
  • Display the bill to the user. The bill includes:
    • The food items
    • The quantities
    • The cost of them
    • The total before tax
    • Tax amount
    • Total price after tax
  • You need to have a main function and get started from the main function.

      The name of functions also up to your design but the names should show what the functions do.

  • Only display 2 decimal points when displaying all the numbers.
  • Put at least two outputs  (results after you run your code) at the end of your code as a multi-line comment.
  • Don't forget to put your name and a short description of your code on the top on your code.
  • Don't forget to test your code with Positive and Negative Testing! (For more information see this page Testing)
  • Your functions should have a docstring which is a short description about what the function is and what it does.

Homework Answers

Answer #1

I have implemented the menu-driven application as per the given description in Python. Please find the following Code Screenshot, output, and Code.

ANY CLARIFICATION REQUIRED LEAVE A COMMENT

1.CODE SCREENSHOT:

2.OUTPUT:

3.CODE :

def readNumber(s):
"""read a number and validate it ,retun a positive number"""
while(True):
ch=input(s).strip();
if ch.isnumeric():
num=int(ch)
if num>0:
return num
else:
print("Your input is not a valid number")
  
def menu():
""" To display the Menu and read Option return the Menu Options """
print("******************************");
print("* MENU *");
print("******************************");
print("\n1.HotDog$2\n2.Salad\t$3\n3.Pizza\t$2\n4.Burger\t$4\n5.Pasta\t$7\n6.Exit");
while True:
op=readNumber("Enter Your Choice:");
if op>0 and op <7:
return op;
def calBill(q):
"""Calculate the Bill and Display the Items,return the Total amount"""
p=[2,3,2,4,7]
total =0;
item=["HotDog","Salad","Pizza","Burger","Pasta"]
print("{:^10s}".format("Item"),"{:^10s}".format("Quantity"),"${:^5s}".format("Price"));
for i in range(len(q)):
sub=0
if(q[i]!=0):
sub=q[i]*p[i];
print("{:^15s}".format(item[i]),"{:^10d}".format(q[i]),"${:^5d}".format(sub));
total=total+sub;
return total;

def calTax(total):
"""Function to calculate the Tax"""
return total*0.09;
def main():
"""main function to read the Option and Calculate the Tax"""
q=[0,0,0,0,0]
while True:
op=menu()
if op==6:
break
num=readNumber("Enter Quantity:");
q[op-1]+=num
  
sf=readNumber("Are you Student(1) or Staff(2)");
print("\nYour Order\n");
total=calBill(q);
tax=0
if(sf==2):
tax=calTax(total);
print("The Total before tax",total);
print("The Tax Amount","{:.2f}".format(tax));
print("The Price After tax:","{:.2f}".format(total-tax));
  

main()

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write a program display the following menu: Ohms Law Calculator 1. Calculate Resistance in Ohms 2....
Write a program display the following menu: Ohms Law Calculator 1. Calculate Resistance in Ohms 2. Calculate Current in Amps 3. Calculate Voltage in volts 4. Quit Enter your choice (1-4) If the user enters 1, the program should ask for voltage in Volts and the current in Amps. Use the following formula: R= E/i Where: E= voltage in volts I= current in amps R= resistance in ohms If the user enters 2 the program should ask for the voltage...
Assignment #4 – Student Ranking : In this assignment you are going to write a program...
Assignment #4 – Student Ranking : In this assignment you are going to write a program that ask user number of students in a class and their names. Number of students are limited to 100 maximum. Then, it will ask for 3 test scores of each student. The program will calculate the average of test scores for each student and display with their names. Then, it will sort the averages in descending order and display the sorted list with students’...
You will write a program that loops until the user selects 0 to exit. In the...
You will write a program that loops until the user selects 0 to exit. In the loop the user interactively selects a menu choice to compress or decompress a file. There are three menu options: Option 0: allows the user to exit the program. Option 1: allows the user to compress the specified input file and store the result in an output file. Option 2: allows the user to decompress the specified input file and store the result in an...
Write a 4-6 sentence summary explaining how you can use STL templates to create real world...
Write a 4-6 sentence summary explaining how you can use STL templates to create real world applications. In your summary, provide an example of a software project that you can create using STL templates and provide a brief explanation of the STL templates you will use to create this project. After that you will implement the software project you described . Your application must be a unique project and must incorporate the use of an STL container and/or iterator and...
Code Example 8-1 1. int count = 1; 2. int item_total = 0; 3. int item...
Code Example 8-1 1. int count = 1; 2. int item_total = 0; 3. int item = 0; 4. while (count < 4) { 5.      cout << "Enter item cost: "; 6.      cin >> item; 7.      item_total += item; 8.      ++count; 9. } 10. int average_cost = round(item_total / count); 11. cout << "Total cost: " << item_total << "\nAverage cost: " << average_cost; (Refer to Code Example 8-1.) If the user enters 5, 10, and 15 at the prompts, the output is: Total...
I've posted this question like 3 times now and I can't seem to find someone that...
I've posted this question like 3 times now and I can't seem to find someone that is able to answer it. Please can someone help me code this? Thank you!! Programming Project #4 – Programmer Jones and the Temple of Gloom Part 1 The stack data structure plays a pivotal role in the design of computer games. Any algorithm that requires the user to retrace their steps is a perfect candidate for using a stack. In this simple game you...
Can someone please edit my code so that it satisfies the assignments' requirements? I pasted the...
Can someone please edit my code so that it satisfies the assignments' requirements? I pasted the codes below. Requirement: Goals for This Project:  Using class to model Abstract Data Type  OOP-Data Encapsulation You are asked to write an app to keep track of a relatively small music library. The app should load song information from a data file once the app is started. It should allow user to view, add, remove, and search for songs. The app should...
Please review the following below and provide , one-page reaction to this budget proposal. 1. Budget...
Please review the following below and provide , one-page reaction to this budget proposal. 1. Budget The President’s Budget and Health Care While the president’s budget is not likely to be acted upon by Congress, it does signal what the administration’s priorities are—as well as what policy initiatives they might push. Repeal the Affordable Care Act: The administration’s budget includes a plan that is based upon the plan put forward by Sens. Lindsey Graham (R-SC) and Bill Cassidy (R-LA) last...
Background You are a manager in the audit division at Miller Yates Howarth (MYH), an accounting...
Background You are a manager in the audit division at Miller Yates Howarth (MYH), an accounting firm with offices throughout the major regional centres of NSW and Queensland. Although a medium sized firm by national standards, MYH is the second largest regional accounting firm in Australia. Most of MYH’s audit clients are in the agriculture, mining, manufacturing and property industries. All of those industries are currently under pressure, either from a downturn in commodity prices or fierce competition from overseas...
You are a manager in the audit division at Miller Yates Howarth (MYH), an accounting firm...
You are a manager in the audit division at Miller Yates Howarth (MYH), an accounting firm with offices throughout the major regional centres of NSW and Queensland. Although a medium sized firm by national standards, MYH is the second largest regional accounting firm in Australia. Most of MYH’s audit clients are in the agriculture, mining, manufacturing and property industries. All of those industries are currently under pressure, either from a downturn in commodity prices or fierce competition from overseas competitors....
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT