## Posted By

skyhook322 on 11/28/09

# my assignment in python

/ Published in: Other

`COMP 1030 - Computer Programming ConceptsAssignment 2, Fall 2009   Write the Python code for the following programming problem.  Please draw the corresponding flowchart also. You may do it by hand or use any software program. Raptor wonÃ¢ï¿½ï¿½t work since it supports a repeat loop (both post-test and pre-test) where as Python only supports the while loop.Write a modular program that will calculate the cost of purchasing a meal.  This program will include decisions and loops.  Details of the program are as follows:Ã¢ï¿½Â¢	Your menu items only include the following food with accompanied price: o	Yum Yum Burger = \$0.99o	Grease Yum Fries = \$0.79o	Soda Yum = \$1.09 Ã¢ï¿½Â¢	Allow the user of the program to purchase any quantity of these items on one order. Ã¢ï¿½Â¢	Allow the user of the program to purchase one or more types of these items on one order.Ã¢ï¿½Â¢	After the order is placed, calculate the sub-totals and the total. Add a 6% sales tax to total to produce the final purchasing price. Ã¢ï¿½Â¢	Print to the screen a receipt showing the total of each item purchased, the sub-total of each item purchased (number purchased by price), the total, the tax and then and the final purchase price. Printing will have to be accomplished in parts in two functions as described below. Functions:Ã¢ï¿½Â¢	main function that controls the program and calls on the other functions. Ã¢ï¿½Â¢	getOrderNumber() that inputs the order number (must be >= 0) and returns it to the main function.Ã¢ï¿½Â¢	takeOrderAndCalculateTotal() that takes the order, calculates the sub-totals and the total value of the order. This function also prints part of the receipt (lines 1-8 in the receipt) that involves the heading, number of items purchased, the sub-totals and total. It returns the total to the calling (main) function.Ã¢ï¿½Â¢	calculateTax(total) that takes as input the total and calculates the tax on it. It returns the tax calculated.Ã¢ï¿½Â¢	calculateFinalPrice(total, tax) and calculates the final purchase price. It also prints the rest of the receipt (lines 9-11) that involves the tax and the final purchasing price and the trailing Ã¢ï¿½ï¿½=Ã¢ï¿½ï¿½. Notes:Ã¢ï¿½Â¢	The program should be well documented. Your name, date and purpose at the beginning, the purpose of each function before its definition at the minimum. Please do not clutter your code with unnecessary comments though.Ã¢ï¿½Â¢	The program runs while the order number is not equal to zero. Ã¢ï¿½Â¢	The valid input in getOrderNumber() for order number is a value >= 0. In case of invalid input, display an error message and let the user re-enter till a valid value is provided.Ã¢ï¿½Â¢	The only valid choices for the menu items in takeOrderAndCalculateTotal()  are 1, 2 and 3. Validate the choice, giving appropriate error message in case of invalid input. Allow user to re-enter till a valid choice is input.Ã¢ï¿½Â¢	The number of items purchased in takeOrderAndCalculateTotal() can be from 1 through 20. Validate the input. Display error message in case of invalid input and allow user to re-enter till a valid value is entered.Ã¢ï¿½Â¢	The user can enter either yes or no as response to the question in takeOrderAndCalculateTotal() Do you want to end your order? (Enter yes or no):   The corresponding loop should execute while the response is no. The condition should check for Ã¢ï¿½ï¿½noÃ¢ï¿½ï¿½ though the user can input in any combination of lower or upper case (no, No etc.). Use the pre-defined function lower of the String class to check for any case-sensitive input.Ã¢ï¿½Â¢	Please declare and use named Ã¢ï¿½ï¿½constantsÃ¢ï¿½ï¿½ for the prices and the sales tax in functions where they are needed and do not use any Ã¢ï¿½ï¿½magic numbersÃ¢ï¿½ï¿½ in your code, either for calculations or for displaying purposes.  Sample Input and Output : 	Please enter order number (>0). Enter 0 to stop the program : 1 	START ORDER : 1 Enter 1 for Yum Yum BurgerEnter 2 for Grease Yum FriesEnter 3 for Soda YumEnter now -> 1Enter the number of burgers you want : 3 Do you want to end your order? (Enter yes or no): no Enter 1 for Yum Yum BurgerEnter 2 for Grease Yum FriesEnter 3 for Soda YumEnter now -> 3Enter the number of sodas you want : 2 Do you want to end your order? (Enter yes or no): no Enter 1 for Yum Yum BurgerEnter 2 for Grease Yum FriesEnter 3 for Soda YumEnter now -> 1Enter the number of burgers you want : 1 Do you want to end your order? (Enter yes or no): no Enter 1 for Yum Yum BurgerEnter 2 for Grease Yum FriesEnter 3 for Soda YumEnter now -> 2Enter the number of fries you want : 2 Do you want to end your order? (Enter yes or no): yes ==================== R E C E I P T ============================Number of burgers ordered		:4Sub-total (@ \$.99 each)		:\$3.96Number of fries ordered		:2Sub-total (@ \$.89 each)		:\$1.58Number of sodas ordered		:2Sub-total (@ \$1.09 each)		:\$2.18Total						:\$7.72Tax at 6%					:\$0.46Final Purchase Price 			:\$8.18 Please enter order number (>0). Enter 0 to stop the program : 2  START ORDER : 2 Enter 1 for Yum Yum BurgerEnter 2 for Grease Yum FriesEnter 3 for Soda YumEnter now -> 2Enter the number of fries you want : 2 Do you want to end your order? (Enter yes or no): no Enter 1 for Yum Yum BurgerEnter 2 for Grease Yum FriesEnter 3 for Soda YumEnter now -> 3Enter the number of sodas you want : 2 Do you want to end your order? (Enter yes or no): yes ==================== R E C E I P T =============================Number of burgers ordered		:0Sub-total (@ \$.99 each)		:\$0.00Number of fries ordered		:2Sub-total (@ \$.99 each)		:\$1.58Number of sodas ordered		:2Sub-total (@ \$1.09 each)		:\$2.18Total						:\$3.76Tax at 6%					:\$0.22Final Purchase Price 			:\$3.98  Please enter order number (>0). Enter 0 to stop the program : 0   HOW TO SUBMIT: 1)	Please submit the flowchart and the Python code (.py file) as two different attachments via blackboard link for Assignment 2. 2)	Submit me a hard copy of both these attachments, with your name on it.`

Posted By: LukeWright on April 26, 2018

Extremely intriguing site to peruse, I have just perused to connect the Custom Dissertation Help UK regarding enhanced your basic academic skills and counselling work. Really composing some thing extraordinary way of learning session are among top choices for every student.

Posted By: John132 on May 18, 2018

In college I and my friend from <a href="> cheap essay writers , thinking about learning a programming language, I thought between Python and C ++, my choice was made towards C ++, because one of the main drawbacks is its relative low execution speed. Python is a language with full dynamic typing, automatic memory management. If at first glance this may seem like an advantage, then when developing programs with increased demand for efficiency, Python can significantly lose speed for its static brothers (C / C ++, Java, Go). As for dynamic cousins ??(PHP, Ruby, JavaScript), everything is much better here, in most cases Python executes code faster, precompiling it in bytecode and most of the standard library written in C.

Posted By: John132 on May 18, 2018

Now my friend and I are working as front-end developers at https://writercheap.com

Posted By: John132 on May 18, 2018

[url=http://www.html.by]HTML[/url]

Posted By: John132 on May 18, 2018

thx for article