Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 resturant sysyem !!!!!!!!!
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
samsungsam




PostPosted: Sat Oct 31, 2009 3:19 pm   Post subject: resturant sysyem !!!!!!!!!

things that i don't know how to make:
after u choose a item make it include tax


Turing:


<Add your code here>
var selection : int
loop
    locate (5, 35)
    put "RYAN'S MENU"
    locate (6, 33)
    put "________________"
    locate (8, 35)
    put "1. OPEN MENU"
    locate (9, 35)
    put "2. MONEY UP TO DATE"
    locate (10, 35)
    put "3. TIPS"
    locate (11, 35)
    put "4. TAX"
    locate (12, 35)
    colour (brightred)
    put "5. EXIT"
    locate (16, 25)
    colour (black)
    put "(Enter 1,2,3,4,5 to start the program)"
    get selection
    exit when selection = 1 or selection = 2 or selection = 3 or selection = 4 or selection = 5
    if selection >= 6 then
    locate (19,25)
        put "(Please insert again only from 1-5!)"
    end if
end loop
cls
loop
var food :string
put skip
colour (green)
put "   -----------------------------------MENU-----------------------------------"
colour (black)
locate (5,5)
put "   =SANDWICHES="
locate (6,5)
put "   1. Turkey Breast.........$4.20"
locate (7,5)
put "   2. Turkey Breast & Ham...$4.40"
locate (8,5)
put "   3. Chicken Breast........$5.00"
locate (9,5)
put "   4. Chicken Teriyaki......$5.00"
locate (10,5)
put "   5. Ham...................$4.20"
locate (11,5)
put "   6. Beef..................$4.60"
locate (12,5)
put "   7. Meatball Marinara.....$4.60"
locate (13,5)
put "   8. BBQ Rib...............$4.70"
locate (14,5)
put "   9. Steak & Cheese........$5.00"
locate (16,5)
put "   =WRAPS="
locate (17,5)
put "   10. Chicken & Bacon......$3.50"
locate (18,5)
put "   11. Turkey Breast & Ham..$2.60"
locate (20,5)
put "   =SALADE="
locate (21,5)
put "   12. Chicken..............$3.60"
locate (22,5)
put "   13. Tuna.................$3.00"
locate (5,40)
put "   =DRINKS="
locate(6,40)
put "   14. Coffee...............$1.95"
locate(7,40)
put "   15. Hot Chocolate........$2.25"
locate(8,40)
put "   16. Tea..................$1.50"
locate(9,40)
put "   17. Juice................$1.75"
locate(10,40)
put "   18. Bottled Water........$1.00"
locate(12,40)
put "   =COOKIES,MUFFINS $ CHIPS="
locate(13,40)
put "   19. Cookies..............$0.50"
locate(14,40)
put "   20. Muffin...............$1.25"
locate(15,40)
put "   21. Chips................$1.00"
locate (24,20)
    get food
exit when food = "Bye"
end loop

cls
put "To Be Continue......"






Sponsor
Sponsor
Sponsor
sponsor
samsungsam




PostPosted: 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




PostPosted: 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 : array 1 .. 21 of
    record
        Name : string
        Price : real
    end record

Menu (1).Name := Name1
Menu (1).Price := Price1
Menu (2).Name := Name2
Menu (2).Price := Price2
...

Or:

Turing:
var MenuItems : array 1 .. 21 of string
var MenuPrices : array 1 .. 21 of real

MenuItems (1) := Name1
MenuPrices (1) := Price1
MenuItems (2) := Name2
MenuPrices (2) := Price2
...

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
end for

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
    end loop

    loop
        %Menu
    end loop
    %exit when the user wants to exit
end loop

You could use an if statement, and a "state" variable, to change between different menus. So:

Turing:

State := 1
%Main loop
loop
    if State = 1 then
        loop
            %Ryans menu
            State := UsersInput
        end loop
    elsif State = 2 then
        loop
            %Menu
        end loop
        State := 1
    end if
    %exit when the user wants to exit
end loop

I hope that helps. Smile
S_Grimm




PostPosted: 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




PostPosted: 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
        label 1 :
            loop
                %Ryans menu
                State := UsersInput
            end loop
        label 2 :
            loop
                %Menu
            end loop
            State := 1           
    end case
    %exit when the user wants to exit
end loop

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




PostPosted: Sun Nov 01, 2009 9:04 pm   Post subject: Re: resturant sysyem !!!!!!!!!

Thank you Supperskull85
Razz
your post help me alot
thanks!!!!!!!!
gianni




PostPosted: 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




PostPosted: 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.


Sorry!
i mean Restaurant System !!!!!!!!!



MENU PROJECT2.T
 Description:

Download
 Filename:  MENU PROJECT2.T
 Filesize:  3.35 KB
 Downloaded:  97 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
samsungsam




PostPosted: Sun Nov 01, 2009 9:20 pm   Post subject: Re: restaurant system !!!!!!!!!

Still Need Help


Array for menu.t
 Description:

Download
 Filename:  Array for menu.t
 Filesize:  474 Bytes
 Downloaded:  83 Time(s)

samsungsam




PostPosted: Sun Nov 01, 2009 9:20 pm   Post subject: Re: restaurant system !!!!!!!!!

still need help


MENU PROJECT2-choice.t
 Description:

Download
 Filename:  MENU PROJECT2-choice.t
 Filesize:  3.44 KB
 Downloaded:  82 Time(s)

samsungsam




PostPosted: 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




PostPosted: 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




PostPosted: 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 = 1 then %Main menu
        loop
            %Ryans menu
            State := UsersInput
            exit when user_provides_correct_input
        end loop
    elsif State = 2 then %Order menu
        for i : 1 .. MaxOrderItems
            %Display order menu items
        end for
        %Ask the user for the number of items
        var UsersItems : array 1 .. UsersNumber
        for i : 1 .. UsersNumber
            %Ask the user for each item
            %Store the item in the array UsersItems
        end for
        %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
    end if
    exit when user_wants_to_exit
end loop

Use a model similar to this and you should be able to do what you want. Smile
samsungsam




PostPosted: 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 = 1 then %Main menu
        loop
            %Ryans menu
            State := UsersInput
            exit when user_provides_correct_input
        end loop
    elsif State = 2 then %Order menu
        for i : 1 .. MaxOrderItems
            %Display order menu items
        end for
        %Ask the user for the number of items
        var UsersItems : array 1 .. UsersNumber
        for i : 1 .. UsersNumber
            %Ask the user for each item
            %Store the item in the array UsersItems
        end for
        %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
    end if
    exit when user_wants_to_exit
end loop

Use a model similar to this and you should be able to do what you want. Smile
[/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




PostPosted: 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
end if

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.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 20 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: