Hello I REALLY need help with an assignment, my teacher is very bad at teaching, and I need help the following is my assignment:

COMP 1030 - Programming Fundamentals

Assignment 3, Fall 2012

Due Date: Wednesday, December 5, 2012, midnight Max Marks: 40

Write the Python code for the following programming problem. Please code using Python 3.2.3.

Write a modular Python 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:

Yum Yum Burger = $0.99

Grease Yum Fries = $0.79

Soda Yum = $1.09

Allow the user of the program to purchase any quantity 0 through 20, of these items on one order. So maximum of 20 for each of the burger, fries and soda can be ordered in one order. The user may choose not to order an item at all.

Allow the user to order any item more than once in the same order.

After the order is placed, calculate the sub-totals and the total. Add a 13% sales tax to total to produce the final purchasing price.

Print to the screen a receipt showing the total number of each item purchased, the sub-total amount of each item purchased (number purchased times price), the total amount, the tax on the total amount and then and the final purchase price.

Functions: These are the functions that MUST be coded. All prompts for required inputs must be complete and clear stating valid values, stopping condition etc. Similarly error messages must be clear and should say what went wrong. Please look at the input/output sample provided to see what I mean. These requirements carry marks in the associated functions.

main() function that controls the program and calls on the other functions as required.(4 marks)

getOrderNumber() that lets the user input a numeric order number (must be >= 0). The user is forced to enter a valid numeric value. It returns the valid value to the calling function.(4 marks)

showMenu() that shows the menu and receives the menu choice from the user. It validates the choice and forces the user to input till a valid value is supplied. If the choice is valid, it returns the menu choice to the calling function.(4 marks)

getItem(itemName, canOrderTheseMany) that inputs the number of items(burgers or fries or soda) ordered and returns it to the calling function. Please ensure that since this is a common function for ordering an ‘item’, the item name appears in the input message. Remember that the valid value is a number 0 through whateverIsLeftOfThatItem. (5 marks)

calculateItemCost(itemName, number_of_item) calculates the cost of the item purchased and returns it.(2 marks)

calculateTotalCost(burgersCost,friesCost, sodasCost) calculates and returns the total cost of the order. (2 marks)

calculateTax(totalCost)) that takes as input the total cost and calculates the tax on it. It returns the tax calculated.(2 marks)

calculateFinalCost(totalCost, tax) takes the total cost and the tax and calculates and returns the final cost. (2 marks)

printAll() function takes as input parameters all that need to be printed and prints the receipt on the screen. Please see sample output below. Your output MUST look exactly like the one provided. All output must be formatted. For currency amount and tax rate show two digits after the decimal point. (5 marks)

Notes:

The program should be well documented. Your name(s), date and purpose at the beginning. Each function must have an explanatory comment before its definition at the least. Please do not clutter your code with unnecessary comments though.(3 marks)

The program runs while the order number is greater than zero. It stops when the order number input is a value of 0.(1 mark)

The valid input in getOrderNumber() for order number is a numeric 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 input choices for the menu items in showMenu() are 1, 2, 3 and 4. Validate the choice, giving appropriate error message in case of invalid input. Force user to re-enter till a valid choice is input.

The number of items purchased of any item must be numeric and should be from 0 through whateverIsLeftOfThatItem. Validate the input in the function getItem(itemName, canOrderTheseMany) whenever an item is ordered. Items can be ordered in ‘whole’ quantities only. Display meaningful error message in case of invalid input and force the user to re-enter till a valid value is entered. Return the valid value from this function.

Do not use any “magic numbers” in your code, either for calculations or for displaying purposes.(3 marks) Use named “global constants” for fixed values that you need in more than one functions and local constants in functions that require them .

All local variables, including the formal parameters need to be declared in comments in the function.(3 marks)

Please do not use global variables in the code. Communication between functions should be through parameter(s) and the return variable(s).

Sample Input and Output: Pay special attention to prompts and error messages. Notice the quantity of an item that can be ordered. The item name and the allowed limit appears with every item ordered. An item can be ordered more than once in an order. For each new order, the maximum quantity of any item ordered is fixed at 20 and reduces as the item order is placed.

======================== NEW ORDER==========================

Please enter order number (>=0). Enter 0 to stop the program: 1

START ORDER: 1

----------------------------------------------- M E N U ------------------------------------------------

Enter 1 for Yum Yum Burger

Enter 2 for Grease Yum Fries

Enter 3 for Soda Yum

Enter 4 to end order

Enter now -> 1

You can order 0 through 20 burgers.

Enter the number of burgers you want: 3

----------------------------------------------- M E N U ------------------------------------------------

Enter 1 for Yum Yum Burger

Enter 2 for Grease Yum Fries

Enter 3 for Soda Yum

Enter 4 to end order

Enter now -> 3

You can order 0 through 20 sodas.

Enter the number of sodas you want: 2

----------------------------------------------- M E N U ------------------------------------------------

Enter 1 for Yum Yum Burger

Enter 2 for Grease Yum Fries

Enter 3 for Soda Yum

Enter 4 to end order

Enter now -> 1

You can order 0 through 17 burgers.

Enter the number of burgers you want: 1

----------------------------------------------- M E N U ------------------------------------------------

Enter 1 for Yum Yum Burger

Enter 2 for Grease Yum Fries

Enter 3 for Soda Yum

Enter 4 to end order

Enter now -> 2

You can order 0 through 20 fries.

Enter the number of fries you want: 2

----------------------------------------------- M E N U ------------------------------------------------

Enter 1 for Yum Yum Burger

Enter 2 for Grease Yum Fries

Enter 3 for Soda Yum

Enter 4 to end order

Enter now -> 3

You can order 0 through 18 sodas.

Enter the number of sodas you want: 20

Input error!!

You can order 0 through 18 sodas.

Enter the number of sodas you want: 0

----------------------------------------------- M E N U ------------------------------------------------

Enter 1 for Yum Yum Burger

Enter 2 for Grease Yum Fries

Enter 3 for Soda Yum

Enter 4 to end order

Enter now -> 4

--------------------Thanks for your order-----------------------

======================= R E C E I P T =========================

Number of burgers ordered :4

Sub-total (@ $.99 each) :$3.96

Number of fries ordered :2

Sub-total (@ $.79 each) :$1.58

Number of sodas ordered :2

Sub-total (@ $1.09 each) :$2.18

Total :$7.72

Tax at 13% :$1.00

-----------------------------------------------------------------

Final Purchase Price :$8.72

=========================== NEW ORDER=======================

Please enter order number (>=0). Enter 0 to stop the program: 2

START ORDER: 2

----------------------------------------------- M E N U ------------------------------------------------

Enter 1 for Yum Yum Burger

Enter 2 for Grease Yum Fries

Enter 3 for Soda Yum

Enter 4 to end order

Enter now -> 2

You can order 0 through 20 fries.

Enter the number of fries you want: 2

----------------------------------------------- M E N U ------------------------------------------------

Enter 1 for Yum Yum Burger

Enter 2 for Grease Yum Fries

Enter 3 for Soda Yum

Enter 4 to end order

Enter now -> 3

You can order 0 through 20 sodas.

Enter the number of sodas you want: 2

----------------------------------------------- M E N U ------------------------------------------------

Enter 1 for Yum Yum Burger

Enter 2 for Grease Yum Fries

Enter 3 for Soda Yum

Enter 4 to end order

Enter now -> 2

You can order 0 through 18 fries.

Enter the number of fries you want: 2

----------------------------------------------- M E N U ------------------------------------------------

Enter 1 for Yum Yum Burger

Enter 2 for Grease Yum Fries

Enter 3 for Soda Yum

Enter 4 to end order

Enter now -> 4

--------------------Thanks for your order-----------------------

======================== R E C E I P T ==========================

Number of burgers ordered :0

Sub-total (@ $.99 each) :$0.00

Number of fries ordered :4

Sub-total (@ $.79 each) :$3.16

Number of sodas ordered :2

Sub-total (@ $1.09 each) :$2.18

Total :$5.34

Tax at 13% :$0.69

-----------------------------------------------------------------

Final Purchase Price :$6.03

=========================== NEW ORDER=======================

Please enter order number (>=0). Enter 0 to stop the program: 0

Another run showing erroneous inputs from the user and error messages that are output.

=========================== NEW ORDER =========================

Please enter order number (>=0). Enter 0 to stop the program: -1

Input Error!

The order number must be 0 or greater.

Please enter order number (>=0). Enter 0 to stop the program: 1

START ORDER: 1

------------------- MENU ------------------

Enter 1 for Yum Yum Burger

Enter 2 for Grease Yum Fries

Enter 3 for Soda Yum

Enter 4 to end order

Enter now -> -2

Input Error!

You must select a value 1 through 4.

Enter now -> 5

Input Error!

You must select a value 1 through 4.

Enter now -> 1

You can order 0 through20 burgers.

Enter the number of burgers you want: -4

Input Error!

You can order 0 - 20 burgers.

Enter the number of burgers you want: 2

------------------- MENU ------------------

Enter 1 for Yum Yum Burger

Enter 2 for Grease Yum Fries

Enter 3 for Soda Yum

Enter 4 to end order

Enter now -> 4

----------------------Thanks for your order----------------------

========================= R E C E I P T =========================

Number of burgers ordered :2

Sub-total (@ $0.99 each) :$1.98

Number of fries ordered :0

Sub-total (@ $0.79 each) :$0.00

Number of sodas ordered :0

Sub-total (@ $1.09 each) :$0.00

Total :$1.98

Tax at 13.00% :$0.26

-----------------------------------------------------------------

Final Purchase Price :$2.24

=================================================================

=========================== NEW ORDER =========================

Please enter order number (>=0). Enter 0 to stop the program: 0

HOW TO SUBMIT:

Please submit the Python code only (.py file) via blackboard link for Assignment 3 by the due date. Please name it Assignment3_yourname(s).py

This is my code so far:

def main():

#loop forever, i.e. keep getting orders until input is 0

#every loop is an order

while (OrderNumber != 0)

print ("======================== NEW ORDER==========================")

#get the order number

#validate inside the function

#make sure number is >= 0

orderNumber = getOrderNumber()

#break exits out of the loop it is placed in

#if the input is 0, we want to stop the program

if(orderNumber == 0):break

#print out the order number

print ("START ORDER:") + str(orderNumber)

#keep getting items for this order until the user wants to end the order

#set initial quantities of items

#for EACH order, the limit is 20

numBurgersLeft = 0

numFriesLeft = 0

numSodasLeft = 0

#ordering stuff from the menu

while True:

#show user menu, get menu selection from them

#inside the function, we get input

#validate the input (1, 2, 3, 4)

#return that value

#menuItem 1 Yum Yum Burger

#menuItem 2 Greasy Yum Fries

menuItem = showMenu()

#get how many of the item we want

#i.e. if menuItem is 1 (Yum Yum Burger) and howManyOfItem is 2, then the person wants 2 Yum Yum Burgers

#need to tell person how many they can order and prompt for number

#need to check if quantity ordered is allowed

if menuItem == 1: #burger

#prompting taken care of in getitem

#passes back number that they want

#0 through number left of that item

howManyOfItem = getItem(menuItem, numBurgersLeft)

elif menuItem == 2:

#first parameter is the item

#second parameter is the number left

howManyOfItem = getItem(menuItem, numFriesLeft)

elif menuItem == 3:

howManyOfItem = getItem(menuItem, numSodasLeft)

else: break

#menuItem is 4 here. We want to end the order.

#what do we put here to end the order, i.e. break out of loop?

#hint: the keyword to break out of a loop was used earlier

#subtract from the quantity left

#need to know which item it is (so we know which quantity to subtract from)

#then subtract number ordered

numBurgersLeft <-----

numFriesLeft

numSodasLeft

#this isn't code

15 burgers left

numBurgersLeft = 15

5 burgers ordered

howManyOfItem = 5

#

if menuItem == 1:

#want this to be new numBurgersLeft <----

# = <- assign values

#assignment operator

# left hand side: variable, not 5, "hello"

# right hand side: value, 5, "hello", variable

numBurgersLeft = numBurgersLeft - howManyOfItem #these two are equivalent

#numBurgersLeft -= howManyOfItem

elif menuItem == 2:

numFriesLeft -=howManyOfItem

else: menuItem == 3:

numSodaLeft -=howManyOfItem

#out of the loop that gets all the items for the order now

print "--------------------Thanks for your order-----------------------"

#order is now complete, want to calculate receipt

#hint: number of burgers ordered is 20 - numBurgersLeft

numBurgersOrdered = 20 - numBurgersLeft

#do same for other menu items

#calculate costs <-----

#get burger cost

#hint: first parameter is the itemName (1)

# second parameter is the number ordered

burgersCost = calculateItemCost(1, numBurgersOrdered)

#can you fill in how to get the other costs?

#get total cost <---------------

totalCost = calculateTotalCost(burgersCost, friesCost, sodasCost) #calculates and returns the total cost of the order. (2 marks)

tax = calculateTax(totalCost) #that takes as input the total cost and calculates the tax on it. It returns the tax calculated.(2 marks)\

finalCost = calculateFinalCost(totalCost, tax) #takes the total cost and the tax and calculates and returns the final cost. (2 marks)

#print the receipt

#what values do we want to print?

printAll(totalCost, tax,........) #function takes as input parameters all that need to be printed and prints the receipt on the screen.

I really need help with this can anyone give me guidance?

Tweet This+ 1 thisPost To Linkedin