Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
case sector is out of range
Author Message
HaVoC

Posted: Fri Dec 05, 2003 2:08 pm   Post subject: case sector is out of range

 code: case boundary of     label 100: put "I am choosing a number between 1, and 100"     label 200: put "I am choosing a number between 1, and 200"     label 300: put "I am choosing a number between 1, and 300"     label 400: put "I am choosing a number between 1, and 400"     label 500: put "I am choosing a number between 1, and 500"     label 600: put "I am choosing a nymber between 1, and 600"     label 700: put "I am choosing a nymber between 1, and 700"     label 800: put "I am choosing a nymber between 1, and 800"     label 900: put "I am choosing a nymber between 1, and 900"     label 1000: put "I am choosing a nymber between 1, and 1000" end case

It says case sector is out of range, what does this mean, and what do I do to fix it?

Also my random number code doesn't work....

randomize
randint(number,1,1000)
What's wrong with this?

Andy

Posted: Fri Dec 05, 2003 2:12 pm   Post subject: (No subject)

cuz u dont have case 2, or 3, or 5 or anything except 100,200,300,400,500,600,700,800,900,1000, just have it from 1 to 10 or have num:=Rand.Int(1,10)*100
Mazer

Posted: Fri Dec 05, 2003 2:16 pm   Post subject: (No subject)

you need another label at the end to handle every other option. meaning, if boundary is anything other than what you have there, the case needs to know what to do:
 code: case boundary of     label 100 :         put "I am choosing a number between 1, and 100"     label 200 :         put "I am choosing a number between 1, and 200"     label 300 :         put "I am choosing a number between 1, and 300"     label 400 :         put "I am choosing a number between 1, and 400"     label 500 :         put "I am choosing a number between 1, and 500"     label 600 :         put "I am choosing a nymber between 1, and 600"     label 700 :         put "I am choosing a nymber between 1, and 700"     label 800 :         put "I am choosing a nymber between 1, and 800"     label 900 :         put "I am choosing a nymber between 1, and 900"     label 1000 :         put "I am choosing a nymber between 1, and 1000"     label :         put "oh no! boundary is a different number!" end case

also, don't use randomize at the beginning of your program, turing uses it automatically every time the program is run.
HaVoC

Posted: Fri Dec 05, 2003 2:17 pm   Post subject: (No subject)

Ok so it'd be

 code: case boundary of case 1:    label 100: put "I am choosing a number between 1, and 100" end case
Mazer

Posted: Fri Dec 05, 2003 2:24 pm   Post subject: (No subject)

 code: label :         % put stuff here to handle all other cases.

after all of your other labels, and before the end case line.

 code: label :         put "unexpected case"

at the end of the case statement thingy, and you ran the program and boundary was 5 or something else that you didn't check for in the case statement the program would put "enexpected case" on the screen
HaVoC

Posted: Fri Dec 05, 2003 2:25 pm   Post subject: (No subject)

Ok I got my case statements to work, but I still have a problem. I chose my number as a fixed value as 777. But it didn't say I am choosing a number between 1 and 800. -.- I think i'm missing something in my case statement
HaVoC

Posted: Fri Dec 05, 2003 2:35 pm   Post subject: (No subject)

And also how do you end the program?
it's in an if statement

 code: if number > 99 then (end code) end if
Andy

Posted: Fri Dec 05, 2003 2:49 pm   Post subject: (No subject)

if ur not in a procedure, the return command exits the program instantly

Mazer

Posted: Fri Dec 05, 2003 3:09 pm   Post subject: (No subject)

HaVoC wrote:
Ok I got my case statements to work, but I still have a problem. I chose my number as a fixed value as 777. But it didn't say I am choosing a number between 1 and 800. -.- I think i'm missing something in my case statement

i think you're trying to use that case statement to check if the number is in a range of values, aren't you? for this (and everything, really) it's better to use if statements. that way:

 code: if boundary < 100 then     put "I am choosing a number between 1, and 100" elsif boundary < 200 then     put "I am choosing a number between 1, and 200" elsif boundary < 300 then     put "I am choosing a number between 1, and 300" elsif boundary < 400 then     put "I am choosing a number between 1, and 400" elsif boundary < 500 then     put "I am choosing a number between 1, and 500" elsif boundary < 600 then     put "I am choosing a number between 1, and 600" elsif boundary < 700 then     put "I am choosing a number between 1, and 700" elsif boundary < 800 then     put "I am choosing a number between 1, and 800" elsif boundary < 900 then     put "I am choosing a number between 1, and 900" elsif boundary < 1000 then     put "I am choosing a number between 1, and 1000" end if

that should work out much better.
HaVoC

Posted: Fri Dec 05, 2003 3:18 pm   Post subject: (No subject)

I'm trying to mae it so that the random number goes into the boundary.
Say the random number was 99
it's day label 100: "i chose a numebr between 1 and 100"
Mazer

Posted: Fri Dec 05, 2003 3:48 pm   Post subject: (No subject)

yes, just use the if statements that i had in the last post.
Dan

Posted: Fri Dec 05, 2003 5:06 pm   Post subject: (No subject)

Mazer wrote:
....for this (and everything, really) it's better to use if statements.

well it dose wrok well for user menuns and anything where you the exacte posable values of the thing being tested.

but it is true that it is not need, i bet if you where able to look at the socre code for it, it whould just be some if stamnets. (that or they just uses c++ switch direlty )
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
HaVoC

Posted: Fri Dec 05, 2003 10:48 pm   Post subject: (No subject)

Ok and 1 last thing. My randint code ain't working. I think i'm missing somehting

 code: randomize randint(number,1,1000)
HaVoC

Posted: Fri Dec 05, 2003 10:52 pm   Post subject: (No subject)

dodge_tomahawk wrote:
if ur not in a procedure, the return command exits the program instantly

I have code after it though

So I have this
 code: if guess = randomnumber then put "Good job, you won the game in ",guessno"(es)" end if

I have code after that if incase he doesn't get it right, it asks for guess2. How can I make the program end if he get's it right?
Dan

Posted: Sun Dec 07, 2003 1:29 am   Post subject: (No subject)

well i am not shure where your ifs are but i am guesing they are in a loop of some kind, in that case you can probly added an exit stament to quite the loop.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 15 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: