ForumsProgramming ForumHow do I Turing?

7 4818
BRAAINZz
offline
BRAAINZz
787 posts
Nomad

So, I am in Grade Ten Programming and we're primarily using Turing with a dash of C# and I want to ask you something: How do I make the computer recognize all numbers within certain parameters during an if?

Or if you would rather:
Eg.

if answer = 1 through 5
then
put "blah-blah."
end if

Something like this, but I can't figure it out.

I want to do this because my class hasn't learned this yet and I feel like going a bit "Above and Beyond" because the work is boring and I feel like making it more entertaining with Easter eggs because I don't want to lose interest half-way through the course.

Please help.

  • 7 Replies
gaboloth
offline
gaboloth
1,612 posts
Peasant

I'm not sure I have 100% understood your question, but it seems you should use those "less than or equal to", "greater than or equal to" things:

if (answer >= 1 && answer = 1 && answer

gaboloth
offline
gaboloth
1,612 posts
Peasant

Uh, I think my post either didn't show up, or it showed up wrong... let me try again...

I'm not sure I have 100% understood your question, but it seems you should use those "less than or equal to", "greater than or equal to" things:

if (answer >= 1 && answer = 1 && answer

gaboloth
offline
gaboloth
1,612 posts
Peasant

I apologize, I didn't think the &lt signs would have messed up with the HTML...

I'm not sure I have 100% understood your question, but it seems you should use those "less than or equal to", "greater than or equal to" things:

if (answer &gt= 1 && answer &lt= 5)
{
put "blah-blah."
}


I don't know Turing so I wrote this in AS3 syntax, tell me if you have trouble understanding it. However, this is what I think it should look like in the language you're using:

if answer &gt= 1 && answer &lt= 5
then
put "blah-blah."
end if

thepunisher93
offline
thepunisher93
1,826 posts
Nomad

in python:-
>>>If answer in range[4:10]:
>>> print " bla bla"
>>>else:
>>> print "BS BS BS"
>>>bla bla bla

BRAAINZz
offline
BRAAINZz
787 posts
Nomad

[quote]if answer >= 1 && answer

BRAAINZz
offline
BRAAINZz
787 posts
Nomad

Sorry, my post got cut off.

[quote]if answer >= 1 && answer

BRAAINZz
offline
BRAAINZz
787 posts
Nomad

This is getting stupid, the site won't post my whole post.

I'll try again. gabolath, good idea, but they wouldn't work. The compiler says that it requires Booleans, which makes little sense to me because Booleans are normally "True" or "False" right? I'll see what my teacher has to say.

Showing 1-7 of 7