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

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...
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...
Write a program that reads a file (provided as attachment to this assignment) and write the...
Write a program that reads a file (provided as attachment to this assignment) and write the file to a different file with line numbers inserted at the beginning of each line. Such as Example File Input: This is a test Example File Output 1. This is a test. (Please comment and document your code and take your time no rush).
[In Python] Write a program that takes a .txt file as input. This .txt file contains...
[In Python] Write a program that takes a .txt file as input. This .txt file contains 10,000 points (i.e 10,000 lines) with three co-ordinates (x,y,z) each. From this input, use relevant libraries and compute the convex hull. Now, using all the points of the newly constructed convex hull, find the 50 points that are furthest away from each other, hence giving us an evenly distributed set of points.
Write a program in python to read from a file the names and grades of a...
Write a program in python to read from a file the names and grades of a class of students to calculate the class average, the maximum, and the minimum grades. The program should then write the names and grades on a new file identifying the students who passed and the students who failed. The program should consist of the following functions: a) Develop a getGrades() function that reads data from a file and stores it and returns it as a...
Using Python to play Checkers: 1) Create classes to represent the necessary objects for game play....
Using Python to play Checkers: 1) Create classes to represent the necessary objects for game play. This will include, at least, the game board, the two types of pieces and the two sides. You will need to determine the best way to represent the relationship between them. 2) Set up one side of the board. Print the status of the board.
For this assignment, you need to write a parallel program in C++ using OpenMP for vector...
For this assignment, you need to write a parallel program in C++ using OpenMP for vector addition. Assume A, B, C are three vectors of equal length. The program will add the corresponding elements of vectors A and B and will store the sum in the corresponding elements in vector C (in other words C[i] = A[i] + B[i]). Every thread should execute an approximately equal number of loop iterations. The only OpenMP directive you are allowed to use is:...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT