[Tutor] College student having python problems

Mark Rourke mark.rourke7 at gmail.com
Fri Dec 7 00:43:03 CET 2012


The Following is my code:

#Mark Rourke, Mitch Lavalle
#Dec 04, 2012
#Global Constants
#Constant Integer MAX_QTY
MAX_QTY = 20
#Constant Real TAX_RATE
TAX_RATE = .13
#Constant Real Burger
Burger = .99
#Constant Real Fries
Fries = .79
#Constant Real Soda
Soda = 1.09
import sys
def getOrderNumber():
#Get the order number from user
#orderNumber >=0
     goodOrder = True
     while goodOrder == True:
         try:
             orderNumber = int(input("Please enter order number, Enter 0 to Stop"))
         except ValueError:
             print("Non numeric input entered. Program terminating...")
         except:
             print("Input Error")
         else:
             if (orderNumber > 0):
                 print ("Your order Number is %d" %(orderNumber))
                 return orderNumber
             elif (orderNumber < 0 or orderNumber != 0):
                 goodOrder = True
                 print ("Please enter a proper value")
            
                 
                 
                 
                 
def showMenu():
#THIS IS ALL PART OF SHOWMENU:
         #keep getting items for this order until the user wants to end the order
                      #set initial quantities of items
     numBurgers=20;
     numFries=20;
     numSodas=20;
     menuItem = showMenu()<---------ERROR THERE<----
                 #ordering stuff from the menu
     menuItem=-1

     while (menuItem!= 0):
                         #show user menu
                          print("    ----------------------------------------------- M E N U ------------------------------------------------")

     print ("Your order Number is %d")

     print("Cost of Burger: %.2f" %Burger)

     print("Cost of Fries: %.2f" %Fries)

     print("Cost of Soda: %.2f" %Soda)

     print("Enter 1 for Yum Yum Burger")

     print("Enter 2 for Grease Yum Fries")

     print("Enter 3 for Soda Yum")

     print("Enter 0 to end order")

     #get menu selection from them

     itemType = int(input("Enter now->"))
                         #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
                         #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
         print("You can order 0 through"+numBurgers+"burgers.")
         numBurgAsked=input("how many would you like?")
         #prompting taken care of in getitem
         #passes back number that they want
     if(numBurgAsked<=numBurgers):
         numBurgers = numBurgers - numBurgAsked
     elif menuItem == 2:
         print("You can order 0 through"+numFries+"fries.")
         numFriesAsked=input("how many would you like?")
     if(numFriesAsked<=numFries):
         numBurgers = numBurgers - numBurgAsked
     elif menuItem == 3:
         print("You can order 0 through"+numSodas+"sodas.")
         numSodasAsked=input("how many would you like?")
     if(numSodasAsked<=numFries):
         numSodas = numSodas - numSodasAsked
            
#THIS IS PART OF CALCULATEFINALCOST:
         #Calculate the cost of each item
         costOfBurgers = calculateCost (1, burgersOrdered)
         costOfFries = calculateCost (2, friesOrdered)
         costOfSodas = calculateCost (3, sodasOrdered)
         totalCost = CalculateTotalCost(1,2,3 + totalTax)
         tax = calculateTax(totalCost * TAX_RATE)
         finalCost = calculateFinalPrice(TotalCost + tax)
         
def main():
     getOrderNumber()
     showMenu()
main()

Okay this is what I've got so far on like 47 i have stated menuItem = 
showMenu()<---------ERROR THERE<----,
thats where I'm getting the error. tI goes into an infinate loop stating 
"File "C:\Users\Mark\Desktop\Assignment3_MarkRourke.py", line 45, in 
showMenu
menuItem = showMenu()"
can you give me some sort of way to get out of this? and if so, can you 
please show me where in the code and how?, I've been working on this for 
over 20 hours my teacher isn't helpful, can you please assist me
------------------------------------------------------------------------

	

Mark Rourke


T: 705-728-6169
M: 705-331-0175
E: Mark.Rourke7 at gmail.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20121206/b1b3fba3/attachment.html>


More information about the Tutor mailing list