Python coffee shop order processing program

This is the place for queries that don't fit in any of the other categories.

Python coffee shop order processing program

Postby bryefellows » Mon Nov 04, 2013 11:12 pm

hello everybody,

I'm having trouble making a coffee shop order processing program. I know it has something to do with while loops and checking for more input, but i don't know how to do the whole program. can someone help me? this is for a midterm and is really a large part of my class. You have to check for input validation as well in the program and print out a receipt.

"You just opened a cafe, and need a simple program with which your servers can enter the orders and print a receipt (for the purpose of this assignment, the printing will be done to the screen, not on paper).

For this assignment, you should write your own menu with item name and price (five items or more), and determine what to print on the receipt (the total amount must be included).

You should also make sure that the input values are valid (i.e. only the items that are in the menu, valid order amount, etc)."

PLEASE HELP!!!!

Brian
Last edited by Mekire on Mon Nov 04, 2013 11:57 pm, edited 1 time in total.
Reason: First post lock.
bryefellows
 
Posts: 6
Joined: Mon Nov 04, 2013 11:05 pm

Re: Python coffee shop order processing program

Postby Mekire » Mon Nov 04, 2013 11:59 pm

We really would love to help, but you are going to need to show us an attempt first. What are you stuck on?
When you do post your attempt, please take care to use code tags.

-Mek
User avatar
Mekire
 
Posts: 1033
Joined: Thu Feb 07, 2013 11:33 pm
Location: Amakusa, Japan

Re: Python coffee shop order processing program

Postby bryefellows » Tue Nov 05, 2013 11:30 pm

im really having a hard time. this is all i came up with so far.

Code: Select all
#Brian Fellows Coffee shop calculator
#main
def main():
        startorder=raw_input("Please select from the following menu:")
        print "1. Bagel"
        print "2. Donut"
        print "3. Coffee"
        print "4. Orange Juice"
        print "5. Muffin"
       
        if moredata == "y"
           print ("Please select from the following menu:)
        else moredata == "n"
           print ("Thank you here is your total:")
main()
Last edited by Mekire on Wed Nov 06, 2013 12:08 am, edited 2 times in total.
Reason: Added code to post.
bryefellows
 
Posts: 6
Joined: Mon Nov 04, 2013 11:05 pm

Re: Python coffee shop order processing program

Postby ochichinyezaboombwa » Wed Nov 06, 2013 3:40 am

To give you some comments on your code,
  • 1) you never use startorder;
  • 2) you use moredata which is never defined;
  • 3) else moredata == "n" is not Python.
Overall, don't want to bring the bad news, but I am afraid it'd be best for you to start your trimester from scratch.
ochichinyezaboombwa
 
Posts: 200
Joined: Tue Jun 04, 2013 7:53 pm

Re: Python coffee shop order processing program

Postby bryefellows » Thu Nov 07, 2013 1:51 pm

Hello again...
Can anyone help me on how to total these items and print out a receipt for them? Any help would be greatly appreciated.
Code: Select all
# -*- coding: cp1252 -*-
#Brian Fellows Coffee shop calculator
#main
def main():       
#Define costs for each item
   bagel = 1.25
   donut = 1.00
   coffee = 1.50
   orangejuice = 1.75
   muffin = 1.50
   total = 0
#set count for each item to 0
   bagelcount = 0
   donutcount = 0
   coffeecount = 0
   orangejuicecount = 0
   muffincount = 0
       
   customer_order = "yes"
   print "Welcome to the Mocha Café"
   print "Please make your selection by number"
   print "Coming soon, more sizes for your coffee and drinks"
   print ""
   print ""
       
   while customer_order[0] == "y":
      print "Please select from the following menu:"
      print "1. Bagel $1.25"
      print "2. Donut $1.00"
      print "3. Coffee $1.50"
      print "4. Orange Juice $1.75"
      print "5. Muffin $1.50"
      print "--------------------------------------------------"
      item=raw_input("Please enter the item you want to purchase:")


# if else nest for items on menu
      if item in ["1", "bagel"]:
         bagelnum = int(input("How many bagels would you like?")) 
         bagelcount = bagelnum + bagelcount 
         total = total + (bagel * bagelnum)
         customer_order=raw_input("Would you like to order more items(y/n):")
         
               
      elif item in ["2", "donut"]:
         donutnum = int(input("How many donuts would you like?")) 
         donutcount = donutnum + donutcount
         total = total + (donut * donutnum)
         customer_order=raw_input("Would you like to order more items(y/n):")
         
      elif item in ["3", "coffee"]:
         coffeenum = int(input("How many coffee would you like?")) 
         coffeecount = coffeenum + coffeecount 
         total = total + (coffee * coffeenum)
         customer_order=raw_input("Would you like to order more items(y/n):")
         
      elif item in ["4", "orange juice"]:
         orangejuicenum = int(input("How many orange juices would you like?")) 
         orangejuicecount = orangejuicenum + orangejuicecount 
         total = total + (orangejuice * orangejuicenum)
         customer_order=raw_input("Would you like to order more items(y/n):")
         
      elif item in ["5", "muffin"]:
         muffinnum = int(input("How many muffins would you like?")) 
         muffincount = muffinnum + muffincount 
         total = total + (muffin * muffinnum)
         customer_order=raw_input("Would you like to order more items(y/n):")
         
      else:
         print "You have entered an invalid item."
         (exit)
              
main ()
Last edited by Mekire on Thu Nov 07, 2013 2:56 pm, edited 1 time in total.
Reason: Lock.
bryefellows
 
Posts: 6
Joined: Mon Nov 04, 2013 11:05 pm

Re: Python coffee shop order processing program

Postby Kebap » Thu Nov 07, 2013 2:49 pm

Hi brye! Glad to see you got some code running for your class. Hope you keep it going! :mrgreen:

Well, it seems to me, you already have prepared the variables like "total" and "bragelcount", etc. So you have most of the data needed for a receipt. Do you need help on how to print text and insert data from a variable? I think you can do it like this:

Code: Select all
print "You are purchasing %s bagels for a total of %s." % (bagelcount, total)

Of course, your logic may be a little more complicated than this.
Learn: How To Ask Questions The Smart Way
Join the #python-forum IRC channel on irc.freenode.net and chat with uns directly!
Kebap
 
Posts: 400
Joined: Thu Apr 04, 2013 1:17 pm
Location: Germany, Europe


Return to General Coding Help

Who is online

Users browsing this forum: Compu-Python, Mekire, Yoriz and 2 guests