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

Username:   Password: 
 RegisterRegister   
 Operands of comparision operators must be scalar,sets or strings help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
dhyanp11




PostPosted: Wed Mar 09, 2016 10:49 am   Post subject: Operands of comparision operators must be scalar,sets or strings help

get name : *
loop
put "Ok ", name, ". Do you want to play the guessing game?"
get firstanswer : *
exit when firstanswer = "yes" or firstanswer = "Yes" or firstanswer = "y"
put
" Invalid! Let's try this one more time."
if firstanswer = "no" or firstanswer = "No" or firstanswer = "n" then
quit
end if
end loop


I am not sure what the error means.
Sponsor
Sponsor
Sponsor
sponsor
Robotkubo




PostPosted: Wed Mar 09, 2016 12:10 pm   Post subject: RE:Operands of comparision operators must be scalar,sets or strings help

Really you need to remove the stars, because there isn't a reason for them... also you haven't set a variable for the name and firstanswer and you'll need to set them to strings. Should look like this

var name : string
var firstanswer : string

get name
loop
put "Ok ", name, ". Do you want to play the guessing game?"
get firstanswer
if firstanswer = "yes" or firstanswer = "Yes" or firstanswer = "y" then
put
"Invalid! Let's try this one more time."
end if
if firstanswer = "no" or firstanswer = "No" or firstanswer = "n" then
quit
end if
end loop
Dreadnought




PostPosted: Wed Mar 09, 2016 4:47 pm   Post subject: Re: Operands of comparision operators must be scalar,sets or strings help

Robotkubo wrote:

Really you need to remove the stars, because there isn't a reason for them...
I disagree, if you want to allow the user to enter a first and last name separated by a space (this appears to be the intent) then this is a good way of doing so.


As for your issue dhyanp11, Robotkubo is correct, you need to define your variables before you use them (the section "Constants and Variables" of http://compsci.ca/v3/viewtopic.php?t=9634 may help).
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  [ 3 Posts ]
Jump to:   


Style:  
Search: