Rewrite your midterm part 1 with these changes: Create a class of order Create an object of an order to run the code. Print the bill on the screen save the bill in a file.
Sample template: (As I mentioned, these all are samples and you can have your own design and naming.) # Creating an object of the class "Order" class Order: ''' The doc string for this class ''' def __ init __(self): self._priceBtax = 0 self._priceAtax = 0 self._tax = 0 # Use dictionaries data structure to save data # Make it as an instance variable.
Then you can fill it and use it everywhere in your class. # you may need 2 dictionaries # "_" means they are private self._priceDict = {"De Anza Burger" : 5.25 , "Bacon Cheese" : 5.75, "Mushroom Swiss" : 5.95, "Western Burger" : 5.95, "Don Cali Burger" : 5.95} # The keys are the order (food) name and the values are the quantities of the orders self._orderDict = {"De Anza Burger" : 0 , "Bacon Cheese" : 0, "Mushroom Swiss" : 0, "Western Burger" : 0, "Don Cali Burger" : 0} def displayMenu(self): ''' The doc string for this method '''
#This is a sample and you can have your own design print("\n----------- De Anza Food Court -----------") number = 1 for key in self._priceDict: print("{a}. {b:15s} {c:8.2f}".format(a= number, b= key, c=self._priceDict[key])) number +=1 print("6. Exit") def getInputs(self): ''' The doc string for this method ''' #You need to fill it # Get the order from the user and fill the "_orderDict" instance variable. # Calculate the price before and after tax def calculate(self): ''' The doc string for this method ''' for key in self.priceDict: self._priceBtax += self._orderDict[key] * self._priceDict[key] self._priceAtax = self._priceBtax + (self._priceBtax * self._tax) # Print the bill on the console def printBill(self): ''' The doc string for this method ''' print("\nYour bill:") print("Your bill:") for key in self._orderDict: print(" %-20s Qty: %-10d Price: $%-10.2f Total: $%-10.2f" %(key, self._orderDict[key],self._priceDict[key], \(self._orderDict[key]*self._priceDict[key]))) print("-"*50) print("Price before tax:" , self.priceBtax) print("Price after tax:" , self.priceAtax) # Save the bill in a file def saveToFile(self): ''' The doc string for this method ''' #You need to fill it Use the following naming style for your file - you may use it in the saveToFile method. import time # <= This line can be on the top of your code timeStamp = time.time() # print(timeStamp)
# <= You don't need this line. I just put it here to show you what the output will be. #1533498418.1082168 import datetime # <= This line can be on the top of your code orderTimeStamp = datetime.datetime.fromtimestamp(timeStamp).strftime('%Y-%m-%d %H-%M-%S') # print(orderTimeStamp) # <= You don't need this line. I just put it here to show you what the output will be. #2018-08-05 12-46-58 # Then concatenate this string with ".txt" orderTimeStamp = orderTimeStamp + '.txt' # 2018-08-05 12-46-58.txt # Now you can use this string as your output file name: with open(orderTimeStamp,'w') as fileHandleToSaveTheBill : In a separate file create two objects and run the related methods: from theFileYouSavedOrderClass import Order if __name__ == "__main__": while True: order = Order() order.displayMenu() order.getInputs() order.calculate() order.printBill() order.saveToFile() help(order) userInputToContinue = input("Continue for another order(Any keys= Yes, n= No)?") if userInputToContinue.lower() == 'n': print("The system is shutting down!") break You MUST use dictionaries to save data. Use strip() function to strip your inputs.
Don't forget Doc Strings for the class and all methods 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 code should show an error if you enter invalid inputs.
Do not forget to submit TWO output text files (their names should be based on the format mentioned above) with your Python file here. >>>>>>>>>>>>>>>>MID TERM PART 1<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Write a menu-driven program for De Anza College 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!) 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. 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
CS 340 Milestone One Guidelines and Rubric Overview: For this assignment, you will implement the fundamental operations of create, read, update,
Retail Transaction Programming Project Project Requirements: Develop a program to emulate a purchase transaction at a retail store. This
7COM1028 Secure Systems Programming Referral Coursework: Secure
Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip
CS 340 Final Project Guidelines and Rubric Overview The final project will encompass developing a web service using a software stack and impleme