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

Username:   Password: 
 RegisterRegister   
 I have a problem with my code
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Kman43759




PostPosted: Tue Oct 07, 2014 8:27 pm   Post subject: I have a problem with my code

What is it you are trying to achieve?



What is the problem you are having?
<whenever I type more than one word in a get, it will come up saying answer x # of words I typed
Example: Program says "Thats mean" and I say "I dont care" ... it will come up saying
Yeah well you are mean
Yeah well you are mean
Yeah well you are mean>


Describe what you have tried to solve this problem
<Lots of stuffs>


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<no i dont want to>

Turing:


var ans, ans2, name : string
put "Please enter your name before you begin"
get name
put "Thankyou, you can now begin talking to Larrybot 1.0"
delay (2000)
put "WARNING: DO NOT USE CAPITALS WHEN TALKING TO LARRYBOT"
delay (2000)
cls
put "Hello"
get ans
loop
    if ans = "hi" then
        put "Hello ", name, " How are you today?"
        get ans2
        if ans2 = "good" then
            put "I'm glad to hear that ", name, "!"
            get ans
        else
            if ans2 = "bad" then
                put "Oh no! Dont worry ", name, " Tommorrow will be a better day!"
                get ans
            else
                if ans2 = "awesome" then
                    put "Thats great ", name, "!"
                    get ans
                end if
            end if
        end if
    end if
    if ans = "hello" then
        put "Hello ", name, " How are you today?"
        get ans2
        if ans2 = "good" then
            put "I'm glad to hear that ", name, "!"
            get ans
        else
            if ans2 = "bad" then
                put "Oh no! Dont worry ", name, " Tommorrow will be a better day!"
                get ans
            else
                if ans2 = "awesome" then
                    put "Thats great ", name, "!"
                    get ans
                end if
            end if
        end if
    end if

    if ans = "hey" then
        put "Hello ", name, " How are you today?"
        get ans2
        if ans2 = "good" then
            put "I'm glad to hear that ", name, "!"
            get ans
        else
            if ans2 = "bad" then
                put "Oh no! Dont worry ", name, " Tommorrow will be a better day!"
                get ans
            else
                if ans2 = "awesome" then
                    put "Thats great ", name, "!"
                    get ans
                end if
            end if
        end if
    end if

    if ans = "yo" then
        put "Hello ", name, " How are you today?"
        get ans2
        if ans2 = "good" then
            put "I'm glad to hear that ", name, "!"
            get ans
        else
            if ans2 = "bad" then
                put "Oh no! Dont worry ", name, " Tommorrow will be a better day!"
                get ans
            else
                if ans2 = "awesome" then
                    put "Thats great ", name, "!"
                    get ans
                end if
            end if
        end if
    end if

    if ans = "shutup" then
        put "that really hurt my feelings ", name
        get ans2
        if ans2 = "i dont care" then
            put "Yeah, well your a mean person"
            get ans
        end if
    end if
end loop






Please specify what version of Turing you are using
<4.1>
Sponsor
Sponsor
Sponsor
sponsor
Kman43759




PostPosted: Tue Oct 07, 2014 8:35 pm   Post subject: RE:I have a problem with my code

Acutally if I type shutup for ans and then I say i dont care, it will come up saying
that really hurt my feelings
that really hurt my feelings
that really hurt my feelings
Tony




PostPosted: Tue Oct 07, 2014 9:20 pm   Post subject: RE:I have a problem with my code

Have you tried reading the documentation for get? It has an example for getting the entire line of text.
code:

var query : string
get query : *   % Entire line is input into query
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Kman43759




PostPosted: Wed Oct 08, 2014 4:14 pm   Post subject: RE:I have a problem with my code

Thankyou! That really helped!
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 1  [ 4 Posts ]
Jump to:   


Style:  
Search: