Hey guys gotta quick question for ya. I'm trying to figure out the best way to write an array for the following:
(1) Hot dog 1.50
(2) Fries 1.00
(3) Lemonade .75
(4) End order
You should be allowed to keep ordering from the menu until you press 4 for End order, at which point you should see a total amount due for your entire order.
I am using menus for the code. This is what I have come up with so far.
start
perform housekeeping()
while response not equal to quitValue
perform mainLoop()
endwhile
perform finishUp()
stop
housekeeping()
declare variables
open files
perform displayMenu()
return
displayMenu()
print “1. HotDog: $1.50”
print “2. Fries: $1.00”
print “3. Lemonade: $0.75”
print “4. End of Order”
print “Please press a number to make a selection”
read response
return
mainLoop()
case based on response
case 1
perform hotDog()
case 2
perform fries()
case 3
perform lemonade()
case 4
perform endOfOrder()
default
print “Sorry. Invalid Entry.”
endcase
perform displayMenu()
return
Now for the hotDog(), fries(), lemonade(), and endOfOrder() modules how would I go about initializing the totalCost variable and have it add up correctly for each? I presume it should be something like this:
if choice = 1 (totalCost = totalCost + 1.50)
if choice = 2 (totalCost = totalCost + 1.00)
if choice = 3 (totalCost = totalCost + 0.75)
if choice = 4 (EXIT LOOP)
output "The total cost of your order is: " totalCost
That's where I am stuck at though. :confused: