var foodcost : array 1 .. 10 of string :=
init ("$3.00", "$1.00", "$2.00", "$1.25", "$1.00", "$0.50", "$4.00", "$3.75", "$2.50", "$2.00")
var foodname : array 1 .. 10 of string :=
init ("1. Hamburger", "2. Pop", "3. French Fries", "4. Chips", "5. Chocolate", "6. Cookie",
"7. Pizza", "8. Sub", "9. Poutine", "10. Brownie")
var a : array 1 .. 10 of real :=
init (3.00, 1.00, 2.00, 1.25, 1.00, 0.50, 4.00, 3.75, 2.50, 1.00)
var food : string
var cost, tax, total, given, give : real
var answer2 : string
cost := 0
tax := 0
var answer : int
var answer3 : string
loop
loop
put "":15, "Food":25, "Cost"
put "":15, "----":25, "----"
put ""
for x : 1 .. 10
put "": 10, foodname (x) : 30, foodcost (x)
end for
locate (20,1)
put "Please enter the number of the food item:"
locate (20, 42)
get answer
if answer < 0 then
put "That is not an available choice please enter the number again."
delay (500)
elsif answer > 10 then
put "That is not an available choice please enter the number again."
delay (500)
elsif answer < 10 then
if answer = 1 or answer = 3 or answer > 6 then
cost := cost + a (answer)
elsif
answer = 2 or answer = 4 or answer = 5 then
cost := cost + a (answer)
tax := tax + a (answer) * 0.15
end if
locate (22,1)
put "Is that everything? (yes/no)"
locate (22,30)
get answer3
exit when answer3 = "yes"
end if
cls
end loop
total := cost + tax
cls
put "The total cost before taxes is: $", cost :2:2
put "The taxes are: $", cost :2:2
put "The final total is: $", total:2:2
delay (2000)
cls
loop
locate (1,1)
put "How much money was given?"
locate (1, 27)
get given
give := given - tax - cost
if give >= 0 then
locate (3,1)
put "Please give the customer : $", give:2:2
delay (3000)
cls
else
put "That is not enough money."
delay (500)
cls
end if
exit when give >= 0
end loop
put "Would you like to make another purchase?"
get answer2
exit when answer2 = "no"
cls
end loop
|