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...
Write a Python program named lastNameVolumes that finds the volumes of different 3 D objects such...
Write a Python program named lastNameVolumes that finds the volumes of different 3 D objects such as a cube, sphere, cylinder and cone. In this file there should be four methods defined. Write a method named cubeVolFirstName, which accepts the side of a cube in inches as an argument into the function. The method should calculate the volume of a cube in cubic inches and return the volume. The formula for calculating the volume of a cube is given below....
I was asked to write a program in CodeBlocks. C++ format. I've written the first half...
I was asked to write a program in CodeBlocks. C++ format. I've written the first half of the code but I am using else and if statements. I feel like the code is too long to do a simple calculation. In CodeBlock when you build and run your code, a new terminal window opens (in windows a new console window) and you can enter your inputs there. It is not like eclipse that you enter your inputs in console view....
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 JAVA PROGRAM 1. Assignment Description Write a stock transaction program that calculates a customer's...
WRITE A JAVA PROGRAM 1. Assignment Description Write a stock transaction program that calculates a customer's profit (or loss) within a certain period of time. 1) First, the program need to get user's name, the stock's code, number of shares and the price he/she purchased the stock, it also asks the user for the price he/she sold the stock later on. The program then compute the following: The amount of money the customer paid for the stock. The amount of...
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...
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...