
-----------------------------------
DaveAngus
Tue Mar 18, 2008 8:20 am

Turing Menu for beginners
-----------------------------------
This code here is very simple and great for anyone starting out in turing.
It only used simple put and get statements,
if statements,
and loops.
If you would like any help with learning how to do this assignment then message me or reply to this and I will be glad to help you.


*****Assignment*****
Create a menu that gives the guests a minimum of 4 choices.
Output a total at the end that includec GST and PST



/*
 Name : Dave Angus
 Date : March 17th 2008
 Task : Menu
 Description: This is a menu for a diner. This menu will give you your choices
 and then it will output your total.
 */
var ch : string (1)


var numapp : int
var total : real
var nument : int
var numdes : int
var tip : real
var option : string


/* This is the options for the appetizers. The
getch (ch)
numapp := strint (ch)
Makes it so that the user only has to type the number of their option as apposed to having to press enter.
 There is a (2000) delay after every option so that the user has time to process their new total.
*/
put "Welcome to Dave's Diner."
put "Here are our options for our dinner menu:"
put "Appetizers"
put "1. Artichoke and cheese dip $7.89"
put "2. Garlic Bread with cheese $4.95"
put "3. Soup and Salad combo $9.99"
put "4. I would not like an appetizer"
getch (ch)
numapp := strint (ch)

if numapp = 1 then
    total := 7.89
elsif numapp = 2 then
    total := 4.95
elsif numapp = 3 then
    total := 9.99
elsif numapp = 4 then
    total := 0
end if

put "Your total so far is: $" ..
put total

delay (2000)
cls



/*This is the entre options*/

put "Entres"
put "1. Burger and fries $8.48"
put "2. Turkey club with fries $9.47"
put "3. Spagetti and meatballs $7.98"
put "4. Steak with a baked potato $12.95"
put "5. Chicken on a bun $8.98"
put "6. I would not like an entre."
getch (ch)
nument := strint (ch)

if nument = 1 then
    total := total + 8.48
elsif nument = 2 then
    total := total + 9.47
elsif nument = 3 then
    total := total + 7.98
elsif nument = 4 then
    total := total + 12.95
elsif nument = 5 then
    total := total + 8.98
elsif nument = 6 then
    total := total + 0
end if

put "Your new total is: $" ..
put total

delay (2000)
cls


/*Here is the section in which people can select the desert that they would like.*/


put "Deserts"
put "1.Ice cream sundae $3.98"
put "2. Ice cream cake $5.99"
put "3. Cheese cake $6.75"
put "4. I would not like desert."
getch (ch)
numdes := strint (ch)

if numdes = 1 then
    total := total + 3.98
elsif numdes = 2 then
    total := total + 5.99
elsif numdes = 3 then
    total := total + 6.75
elsif numdes = 4 then
    total := total + 0
end if


put "Your new total is: $" ..
put total

put "Would you like to add a tip? (yes or no)"
get option

if option = "yes" then
    put "How much? "
    get tip

    total := total + tip
elsif option = "no" then

    put "Alright"

end if

/*Ending statement*/

put "Thanks for coming to Dave's Diner!"
put "GST :", total * 0.08
put "PST :", total * 0.06
put "Total :", total * 1.14

-----------------------------------
DaveAngus
Tue Mar 18, 2008 9:18 am

RE:Turing Menu for beginners
-----------------------------------
Anyone like this code?

-----------------------------------
BigBear
Tue Mar 18, 2008 1:55 pm

Re: Turing Menu for beginners
-----------------------------------
I am just wondering why you are converting the string entered by the user into an interger. I understand you want to use getch which means your variable must be a string 1 character in length but you put the option in your if statement in quatations. 
PREVIOUS
getch (ch)
numapp := strint (ch)

if numapp = 1 then
total := 7.89
elsif numapp = 2 then
total := 4.95
elsif numapp = 3 then
total := 9.99
elsif numapp = 4 then
total := 0
end if
TO
getch (ch)
if numapp = "1" then
total := 7.89
elsif numapp = "2" then
total := 4.95
elsif numapp = "3" then
total := 9.99
elsif numapp = "4" then
total := 0
end if

Also you could ask the user prior the displaying the selection if they are interested in that course. For example asking if they want dessert before showing the selection but still allowing them to choose none.

-----------------------------------
DaveAngus
Wed Mar 19, 2008 7:59 am

RE:Turing Menu for beginners
-----------------------------------
THanks BigBear for the input.
So what your saying is I should just take the

numapp := strint (ch)

part out?

-----------------------------------
Kharybdis
Wed Mar 26, 2008 12:04 pm

Re: Turing Menu for beginners
-----------------------------------
This could be made a LOT shorter. However, i commend your effort. Try learning more about turing to enhance your knowledge.

-----------------------------------
syntax_error
Wed Mar 26, 2008 12:29 pm

Re: Turing Menu for beginners
-----------------------------------

This could be made a LOT shorter. However, i commend your effort. Try learning more about turing to enhance your knowledge.


You know the point is to explain how he/she could do such a thing not to keep make random comments that are so vague there is no point to them.

-----------------------------------
DaveAngus
Wed Mar 26, 2008 1:01 pm

RE:Turing Menu for beginners
-----------------------------------
This was made for Beginners.
If I start using arrays and what not,
BEGINNERS wont understand it.
I am trying to keep it very simple!

-----------------------------------
Vermette
Wed Mar 26, 2008 1:15 pm

Re: RE:Turing Menu for beginners
-----------------------------------
This was made for Beginners.
If I start using arrays and what not,
BEGINNERS wont understand it.
I am trying to keep it very simple!

If I was teaching introductory programming in a high school environment, I think this would be an appropriate program to demonstrate different control statements :).  No need to focus on clever optimization yet!

-----------------------------------
DaveAngus
Fri Mar 28, 2008 9:15 am

RE:Turing Menu for beginners
-----------------------------------
Thats what i was saying was it not? Look at my code.
When I say keeping it simple I mean use lots of puts and gets,
no arrays
and use some simple if statements.

-----------------------------------
SIXAXIS
Fri Mar 28, 2008 10:34 pm

Re: Turing Menu for beginners
-----------------------------------
I know this is for beginners but you should have it round the grand total and for a more "advanced" tutorial (if you do one), use the GUI module, it makes everything more user friendly.

-----------------------------------
DaveAngus
Sun Mar 30, 2008 8:52 pm

Re: Turing Menu for beginners
-----------------------------------
I know this is for beginners but you should have it round the grand total and for a more "advanced" tutorial (if you do one), use the GUI module, it makes everything more user friendly.

Thanks for the input SIXAXIS.
For the rounding, are you meaning to two decimal points or to the nearest dollar?

Thanks again,
-Dave
