Posted: Sat Oct 31, 2009 3:23 pm Post subject: Re: resturant sysyem !!!!!!!!!
after i choose food menu whice code that i can use and make it turn back to the first menu
Ryan's menu >food menu
food menu > Ryan's Menu
should i use loop or if,end if or array?
show me a example plz
Superskull85
Posted: Sat Oct 31, 2009 5:56 pm Post subject: Re: resturant sysyem !!!!!!!!!
I think your best bet for adding tax is to use either an array filled with a record, or parallel arrays (not recommended, but if you have not learned how to use records, this might be what your teacher wants). So either:
Turing:
var Menu :array1.. 21of record
Name :string
Price :real endrecord
Menu (1).Name := Name1
Menu (1).Price := Price1
Menu (2).Name := Name2
Menu (2).Price := Price2
...
Or:
Turing:
var MenuItems :array1.. 21ofstring var MenuPrices :array1.. 21ofreal
If you wanted to separate the foods into categories dynamically you could add another field to the record, or another parallel array. Either way you can output the menu using a counted loop:
Turing:
for i :1.. 21 %put name of item + price of item endfor
And separate the items by category statically (for example, going from 1 to 9 for sandwiches), or dynamically checking a "category" field.
If you put the menu into an array than the number the user enters becomes the index where the food is in the array, so just use something like:
Turing:
Total := Menu (user selection).Price *(1 + tax percentage) %or
Total := MenuPrices (user selection)*(1 + tax percentage)
To go back to the Ryan's Menu -> Menu, or Menu -> Ryan's Menu, you need to embedded loops. The outer most loop would be your main loop (only broken when the user wants to exit) and the inner most loops would be used for each menu. So:
Turing:
%Main loop loop loop %Ryans menu endloop
loop %Menu endloop %exit when the user wants to exit endloop
You could use an if statement, and a "state" variable, to change between different menus. So:
Turing:
State :=1 %Main loop loop if State =1then loop %Ryans menu
State := UsersInput
endloop elsif State =2then loop %Menu endloop
State :=1 endif %exit when the user wants to exit endloop
I hope that helps.
S_Grimm
Posted: Sat Oct 31, 2009 8:26 pm Post subject: RE:resturant sysyem !!!!!!!!!
id look into switch case statements depending on which menu they wanted (ie a case for drinks, a case for desserts, a case for main course, a case for appetizers, etc etc etc)
mind you i cant remember the turing switch/case statement layout so im not even going to attempt to post any code for it
Superskull85
Posted: Sun Nov 01, 2009 12:22 am Post subject: RE:resturant sysyem !!!!!!!!!
You could use case statement for states like this:
Turing:
State :=1 %Main loop loop case State of label1: loop %Ryans menu
State := UsersInput
endloop label2: loop %Menu endloop
State :=1 endcase %exit when the user wants to exit endloop
But it doesn't really matter if you use an if statement, or case statement, as they accomplish similar goals.
If statements are more flexible in terms of what you can do, so I tend to stick with them. Turing does not "cascade" to subsequent branches in a case statement, so other than shortening code, they really don't have to much use over if statements.
samsungsam
Posted: Sun Nov 01, 2009 9:04 pm Post subject: Re: resturant sysyem !!!!!!!!!
Thank you Supperskull85
your post help me alot
thanks!!!!!!!!
gianni
Posted: Sun Nov 01, 2009 9:07 pm Post subject: RE:resturant sysyem !!!!!!!!!
Please double-check your title and post, poor spelling makes me less inclined to assist you.
samsungsam
Posted: Sun Nov 01, 2009 9:13 pm Post subject: Re:Wrong Spelling
Still Need Help
gianni wrote:
Please double-check your title and post, poor spelling makes me less inclined to assist you.
Posted: Sun Nov 01, 2009 9:23 pm Post subject: Re: restaurant system !!!!!!!!!
how do i combine array for menu and menu project 2-choice together
menu project-choice + array for menu
when i combine them together
it is an error
can any one help me fix it?
plz
rdrake
Posted: Sun Nov 01, 2009 10:57 pm Post subject: RE:resturant sysyem !!!!!!!!!
If I'm not mistaken you can edit your post until somebody has replied to it. Incidentally somebody did reply to your last 3 posts, albeit it was you.
Quadruple, let alone triple, let alone double posts are frowned upon here. Please exercise patience, particularly since your past 4 posts were within 10 minutes of one another.
Superskull85
Posted: Mon Nov 02, 2009 11:37 am Post subject: Re: restaurant system !!!!!!!!!
samsungsam @ Sun Nov 01, 2009 9:23 pm wrote:
how do i combine array for menu and menu project 2-choice together
menu project-choice + array for menu
when i combine them together
it is an error
can any one help me fix it?
plz
Well you should list how you want the program to function first. An example:
Show the main menu, get the users input and execute the appropriate choice
If the user chose to see the order menu, delete the main menu and show order menu
Ask the user how many items they want to order.
Get those items.
Find the price of those items by comparing the users choices with the order menu.
Calculate the tax per item, and than calculate the total.
Complete order.
By following a plan like the above you should be able to complete the program.
You know that the main menu needs to exist in a loop. Inside that loop you get the users input, and determine the current state of the program.
Within the "order menu" state you need to display the order menu, ask the user how many items they want, etc.
It would look something like this:
Turing:
State :=1 %Main loop loop if State =1then%Main menu loop %Ryans menu
State := UsersInput
exitwhen user_provides_correct_input
endloop elsif State =2then%Order menu for i :1.. MaxOrderItems
%Display order menu items endfor %Ask the user for the number of items var UsersItems :array1.. UsersNumber
for i :1.. UsersNumber
%Ask the user for each item %Store the item in the array UsersItems endfor %Check the items in UsersItems with the order menu %Calculate the price and tax per item
UsersTotal := sum_of_item_prices %Calculate the total owed %Output the total to the user
State :=1%Go back to main menu endif exitwhen user_wants_to_exit
endloop
Use a model similar to this and you should be able to do what you want.
samsungsam
Posted: Mon Nov 02, 2009 1:11 pm Post subject: Re: resturant sysyem !!!!!!!!!
samsungsam @ Sun Nov 01, 2009 9:23 pm wrote:
how do i combine array for menu and menu project 2-choice together
menu project-choice + array for menu
when i combine them together
it is an error
can any one help me fix it?
plz
Well you should list how you want the program to function first. An example:
Show the main menu, get the users input and execute the appropriate choice
If the user chose to see the order menu, delete the main menu and show order menu
Ask the user how many items they want to order.
Get those items.
Find the price of those items by comparing the users choices with the order menu.
Calculate the tax per item, and than calculate the total.
Complete order.
By following a plan like the above you should be able to complete the program.
You know that the main menu needs to exist in a loop. Inside that loop you get the users input, and determine the current state of the program.
Within the "order menu" state you need to display the order menu, ask the user how many items they want, etc.
It would look something like this:
Turing:
State :=1 %Main loop loop if State =1then%Main menu loop %Ryans menu
State := UsersInput
exitwhen user_provides_correct_input
endloop elsif State =2then%Order menu for i :1.. MaxOrderItems
%Display order menu items endfor %Ask the user for the number of items var UsersItems :array1.. UsersNumber
for i :1.. UsersNumber
%Ask the user for each item %Store the item in the array UsersItems endfor %Check the items in UsersItems with the order menu %Calculate the price and tax per item
UsersTotal := sum_of_item_prices %Calculate the total owed %Output the total to the user
State :=1%Go back to main menu endif exitwhen user_wants_to_exit
endloop
Use a model similar to this and you should be able to do what you want.
[/quote]
sorry, but i don't get what you mean.
can you be more detail plz?
can you put a running total in it?
-----------------------------------------------------------------------
main menu
-1. food menu
-how many you want
-receipt
-how many tips do they want to pay
-2. total sale
-show how many item you sale($) tax and tips not include
-3. tips (running total)
-how many tips($) you get
-4. tax (running total )
-how many tax$($) money
-5. grand total
-total sale + tips + tax
-6. exit
-----------------------------------------------------------------------
That is actually what i suppose to make
Superskull85
Posted: Mon Nov 02, 2009 6:18 pm Post subject: RE:resturant sysyem !!!!!!!!!
The idea is to use a similar model to the one I outlined, and to program each individual parts of the program. I will not do your assignment for you.
That being said, I would be willing to help you out, if you at least attempt a solution.
Your "MENU PROJECT2.t" file already has basic functionality for displaying the main menu, displaying the order menu if the user wants to see it, asking the user for the number of items they wish to order, asking for those items and getting those items.
What you need to do now is figure out the prices for each item the user enters. This can be done using a for loop and some if statements.
The for loop would iterate through each item the user entered (the array "item" in the file I mentioned), and checking those item to see if they match a choice in your order menu. For example, one of the if statements could be:
Turing:
if item[i]="Turkey Breast"then %Calculate the price with tax %Add the price with tax to the total amount endif
Than all you have to do is complete the order.
If you need to calculate total tax than multiply each price by (TaxPercentage / 100) and add that to the total tax. Tips can be incorporated by asking if the user wants to give a tip upon completion of the order, and adding that to the tip total.