Computer Science Canada Pizza Shop help |
Author: | dalandude [ Thu Apr 14, 2011 11:02 am ] |
Post subject: | Pizza Shop help |
Hi I'm having some difficulty with a program :S I need to have it so the user can input the ammount of change they are paying the pizza shop after the pizza shop gives them a total. Then the pizza shop has to give them change for what they pay. Here is the code I only have it working at the point where it's pepperoni pizza. so just type pepperoni then small or large to see the program's actions: var size : string var type_pizza : string var sub_total_p : int := 0 var sub_total_h : int := 0 var sub_total_m : int := 0 var pepperonis : char var peppers : char var mushrooms : char var pineapple : char var subtotal_custom : int var user_pay : int %============================================================================= procedure pepperoni (size, type_pizza : string) if size = "large" then % drawfilloval (550, 100, 100, 100, 43) % drawfilloval (550, 100, 85, 85, brightred) % drawfilloval (550, 100, 70, 70, yellow) % drawfilloval (550, 120, 10, 10, red) % drawfilloval (540, 90, 10, 10, red) sub_total_p := sub_total_p + 900 elsif size = "small" then % drawfilloval (550, 100, 75, 75, 43) % drawfilloval (550, 100, 65, 65, brightred) % drawfilloval (550, 100, 55, 55, yellow) % drawfilloval (550, 120, 10, 10, red) % drawfilloval (540, 90, 10, 10, red) % drawfilloval (560, 70, 10, 10, red) % drawfilloval (520, 130, 10, 10, red) % drawfilloval (520, 70, 10, 10, red) % drawfilloval (580, 100, 10, 10, red) sub_total_p := sub_total_p + 700 end if end pepperoni %============================================================================= procedure hawaiian (size, type_pizza : string) if size = "large" then % drawfilloval (550, 100, 100, 100, 43) % drawfilloval (550, 100, 85, 85, brightred) % drawfilloval (550, 100, 70, 70, yellow) sub_total_h := sub_total_h + 1000 elsif size = "small" then % drawfilloval (550, 100, 75, 75, 43) % drawfilloval (550, 100, 65, 65, brightred) % drawfilloval (550, 100, 55, 55, yellow) sub_total_h := sub_total_h + 800 end if end hawaiian %============================================================================= procedure meat (size, type_pizza : string) if size = "large" then % drawfilloval (550, 100, 100, 100, 43) % drawfilloval (550, 100, 85, 85, brightred) % drawfilloval (550, 100, 70, 70, yellow) sub_total_m := sub_total_m + 1100 elsif size = "small" then % drawfilloval (550, 100, 75, 75, 43) % drawfilloval (550, 100, 65, 65, brightred) % drawfilloval (550, 100, 55, 55, yellow) sub_total_m := sub_total_m + 900 end if end meat %============================================================================= procedure custom (type_pizza, size : string) end custom %============================================================================= put "What kind of pizza do you want?(pepperoni, hawaiian, meat)" get type_pizza cls put "What size? small / large" get size cls if type_pizza = "pepperoni" then pepperoni (size, type_pizza) elsif type_pizza = "hawaiian" then hawaiian (size, type_pizza) elsif type_pizza = "meat" then meat (size, type_pizza) elsif % CUSTOM TIME type_pizza = "custom" then put "Do you want Pepperonis? Y / N" get pepperonis cls put "Do you want peppers? Y / N" get peppers cls put "Do you want mushrooms? Y / N" get mushrooms cls put "Do you want Pineapple? Y / N" get pineapple cls % HARDCORE CODING FOR CUSTOM PIZZA COMMENCING NOW! if size = "large" then % drawfilloval (550, 100, 100, 100, 43) % drawfilloval (550, 100, 85, 85, brightred) % drawfilloval (550, 100, 70, 70, yellow) subtotal_custom := subtotal_custom + 8 elsif size = "small" then % drawfilloval (550, 100, 75, 75, 43) % drawfilloval (550, 100, 65, 65, brightred) % drawfilloval (550, 100, 55, 55, yellow) subtotal_custom := subtotal_custom + 6 end if if pepperonis = "y" then % drawfilloval (550, 120, 10, 10, red) % drawfilloval (540, 90, 10, 10, red) % drawfilloval (560, 70, 10, 10, red) % drawfilloval (520, 130, 10, 10, red) % drawfilloval (520, 70, 10, 10, red) % drawfilloval (580, 100, 10, 10, red) subtotal_custom := subtotal_custom + 1 end if if peppers = "y" then else put "THAT'S NOT A PIZZA!!!" end if end if if type_pizza = "custom" then put subtotal_custom elsif type_pizza = "pepperoni" then put "Your subtotal comes to $", sub_total_p div 100 put "Your total comes to $", sub_total_p / 1300 + sub_total_p / 100 put "How much will you pay? IN CENTS!!!" get user_pay elsif type_pizza = "hawaiian" then put sub_total_h elsif type_pizza = "meat" then put sub_total_m end if |
Author: | Tony [ Thu Apr 14, 2011 11:59 am ] | ||
Post subject: | RE:Pizza Shop help | ||
I love how if one is not ordering peppers as a topping, the program just yells that this is not a real pizza, but continues on with the order anyway. Was there a question in your post? |
Author: | Raknarg [ Thu Apr 14, 2011 1:30 pm ] |
Post subject: | RE:Pizza Shop help |
Lol, Dalan, is this the one due today? I thought you were getting extra time so you could get a windows computer? Anyways, have you tried using math? ![]() Money - Cost = Change |
Author: | dalandude [ Thu Apr 14, 2011 4:10 pm ] |
Post subject: | RE:Pizza Shop help |
I tried that, didn't really work out xD And Tony, Ignore that part of the code, I haven't finished with it yet xD |
Author: | Tony [ Thu Apr 14, 2011 4:13 pm ] |
Post subject: | Re: RE:Pizza Shop help |
dalandude @ Thu Apr 14, 2011 4:10 pm wrote: I tried that, didn't really work out xD
You'd have to be more specific. What didn't work? |
Author: | vahnx [ Sat Apr 16, 2011 8:01 pm ] |
Post subject: | RE:Pizza Shop help |
Try subtracting the user_pay from the cost of the pepperoni pizza like Raknarg suggests. |
Author: | munt4life [ Mon May 02, 2011 7:28 pm ] |
Post subject: | Re: Pizza Shop help |
total money - cost = change set up variables for example x and set it to a fixed cost this will be your total amount of money. then make a get statement so the user can input how much the cost is so then you can easily make a put statement saying what the change is. |
Author: | Raknarg [ Mon May 02, 2011 7:30 pm ] |
Post subject: | RE:Pizza Shop help |
Guys, don't worry about this, I solved it with him ![]() |