Question

In: Computer Science

Need this program Using Classes , Objects, Save to file, and Printbill Simple python assignment Write...

Need this program Using Classes , Objects, Save to file, and Printbill Simple python assignment

Write a menu-driven program for Food Court. (You need to use functions!) Display the food menu to a user (Just show the 5 options' names and prices - No need to show the Combos or the details!) Ask the user what he/she wants and how many of it. (Check the user inputs) AND Use strip() function to strip your inputs. Keep asking the user until he/she chooses the end order 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. Tax Cupertino 9.000% Santa Clara 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 can have your own design but you need to have a main function and get started from the main function. For example: def main(): displayMenu() . . displayBill(..) main() or if __name__ == "__main__": main() The name of functions also up to your design but they 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)

Solutions

Expert Solution

code

solution

//output

//copyable code

# display menu
def menu_show(Items_menu):
i1 = 1
print("Item Name\t Price")

for menu_Item in Items_menu:
print(str(i1) + ". " + str(menu_Item[0]) + "\t " + str(menu_Item[1]))
i1 = i1 + 1
# taking inputs


def get_data():
items=["Icecream", "Jaffa cakes","Pot Noodle", "Frenchfries","Sausage rolls"]
  
order1 = []
item_name = int(input())
print("Please enter the quantity: ")
Quantity = int(input())
order1.append(items[item_name - 1])
order1.append(Quantity)
return order1


# bill
def computebill(order_List, Items_menu):
print("Are you a student or a staff?")
bill1 = 0.0
tax1 = 0
bill_amt = []
for order in order_List:
for menu_Item in Items_menu:
if order[0] == menu_Item[0]:
bill1 = bill1 + (order[1] * menu_Item[1])
stuOrSta = input()
if stuOrSta == "staff":
tax1 = bill1 * (9 / 100)
else:
tax1 = 0.0

bill_amt.append(bill1)
bill_amt.append(tax1)
return bill_amt


# display bill
def display_bill(order_List, Items_menu, bill_amt):
print("Item Name\t Price\t Quantity")

for order in order_List:
for menu_Item in Items_menu:
if order[0] == menu_Item[0]:
print(str(menu_Item[0]) + "\t " + str(menu_Item[1]) + "\t " + str(order[1]))
  
print("Amount: \t\t"+"{:.2f}".format((bill_amt[0])));
  
print("Tax:\t\t"+"{:.2f} " .format((bill_amt[1])))
total_Amt = bill_amt[0] + bill_amt[1]
print("Amount:\t\t"+"{:.2f} " .format((total_Amt)))


def main():
Items_menu = [["Icecream", 2], ["Jaffa cakes", 3], ["Pot Noodle", 1.75], ["Frenchfries", 1.5], ["Sausage rolls", 2.3]]
order_List = []
while True:
menu_show(Items_menu)
order = get_data()
order_List.append(order)
print("Do you want to place another order? (y/n)")
choice = input()
if choice == "n":
break
bill_amt = computebill(order_List, Items_menu)
display_bill(order_List, Items_menu, bill_amt)


if __name__ == "__main__":
main()


Related Solutions

Assignment: (Save this file as A7-1.cpp) Write a program to calculate the gross pay for an...
Assignment: (Save this file as A7-1.cpp) Write a program to calculate the gross pay for an assembly line employee that works for a company that pays all assembly line workers $7.50 hour. Any employee that works over 40 hours per week is compensated by being paid time-and-one-half for each hour over 40. a. Use main( ) as the driver function. Allow the user to compute as many employees as desired. b. Write the function getName( ) that prompts for the...
write a c# program that: The file is using a very simple form of compression in...
write a c# program that: The file is using a very simple form of compression in which there are no spaces, each word is separated by camel casing. For Example, the string "TheCatWillRun" is parsed as "The Cat Will Run". *Now for the statistics* Prints to the console the following statistics about the content in the file retrieved above. - How many of each letter are in the file - How many letters are capitalized in the file - The...
Write a Java Program using the concept of objects and classes. Make sure you have two...
Write a Java Program using the concept of objects and classes. Make sure you have two files Employee.java and EmployeeRunner.java. Use the template below for ease. (Please provide detailed explanation) Class Employee Class Variables: Name Work hour per week Hourly payment Class Methods: - Get/Sets - generateAnnualSalary(int:Duration of employment)               annual salary = Hourly payment * Work hours per week * 50 If the employee is working for more than 5 years, 10% added bonus             -void displayAnnualSalary ( )...
Classes and Objects Write a program that will create two classes; Services and Supplies. Class Services...
Classes and Objects Write a program that will create two classes; Services and Supplies. Class Services should have two private attributes numberOfHours and ratePerHour of type float. Class Supplies should also have two private attributes numberOfItems and pricePerItem of type float. For each class, provide its getter and setter functions, and a constructor that will take the two of its private attributes. Create method calculateSales() for each class that will calculate the cost accrued. For example, the cost accrued for...
Using steps.py in this repository for a starter file, write a Python program to calculate average...
Using steps.py in this repository for a starter file, write a Python program to calculate average number of steps per month for a year. The input file (which you will read from the command line, see the sample program on how to read command line arguments in this repository) contains the number of steps (integer) a person took each day for 1 year, starting January 1. Each line of input contains a single number. Assume this is NOT a leap...
Python: Write a program that asks the user for the name of a file. The program...
Python: Write a program that asks the user for the name of a file. The program should display the contents of the file line by line.
Write a python program: There is a file called file 2. File2 is a txt file...
Write a python program: There is a file called file 2. File2 is a txt file and I have written the contents of file 2 below in the exact format it was in notepad. # This comment does not make sense # It is just to make it harder # The job description starts after this comment, notice that it has 4 lines. # This job description has 700150 hay system points\\ the incumbent will administer the spending of kindergarden...
For Python: In this assignment you are asked to write a Python program to determine the...
For Python: In this assignment you are asked to write a Python program to determine the Academic Standing of a studentbased on their CGPA. The program should do the following: Prompt the user to enter his name. Prompt the user to enter his major. Prompt the user to enter grades for 3 subjects (A, B, C, D, F). Calculate the CGPA of the student. To calculate CGPA use the formula: CGPA = (quality points * credit hours) / credit hours...
In this PYTHON 3 program assignment, you will find a text file named WorldSeries.txt. This file...
In this PYTHON 3 program assignment, you will find a text file named WorldSeries.txt. This file contains a chronological list of the World Series' winning teams from 1903 through 2018. The first line in the file is the name of the team that won in 1903, and the last line is the name of the team that won in 2018. (Note the World Series was not played in 1904 and 1994. There are entries in the file indicating this.) Write...
Write a program using python that loops over each file in a specified directory and checks...
Write a program using python that loops over each file in a specified directory and checks the size of each file.You should create 2-tuple with the filename and size, should append the 2-tuple to a list, and then store all the lists in a dictionary.  
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT