Computer Science Canada

yes or no

Author:  blankout [ Wed Apr 01, 2009 4:48 pm ]
Post subject:  yes or no

is it possible to use an or statement for something like a yes or no answer like

Turing:

if answer="yes" or "no"
then


is this possible or am i just being stupid?

Author:  Tony [ Wed Apr 01, 2009 5:06 pm ]
Post subject:  RE:yes or no

code:

if boolean_expression or boolean_expression then
   ...

Author:  Insectoid [ Wed Apr 01, 2009 5:14 pm ]
Post subject:  RE:yes or no

Tony, I think he means 'if A = b or C'

You have to type 'A' twice.

So, it would look like so;
code:

if answer = "yes" or answer = "no" then
    %whatever
end if

However, it seems quite illogical to have yes or no in the same one I would split it out. 'elsif' is your friend here.
code:

if answer = "yes" then
    %whatever
elsif answer = "no" then
    %whatever else
end if


There is also the 'else' command. Basically, if it isn't any of those things, do this.
code:

if answer = "yes" then
    %whatever
elsif answer = "no" then
    %whatever else
else
    put "this happens if answer doesn't equal yes or no"
end if

Author:  Tony [ Wed Apr 01, 2009 5:18 pm ]
Post subject:  RE:yes or no

the hint was that "no" is not a boolean expression.

Author:  Insectoid [ Wed Apr 01, 2009 8:15 pm ]
Post subject:  RE:yes or no

perhaps he doesn't know even what a boolean expression is, Tony. You have to remember that these kids no almost nothing about programming or even things as obscurely related to it as boolean expressions.


: