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

Username:   Password: 
 RegisterRegister   
 Request - Can someone post a example of case selection?
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
FeniX




PostPosted: Fri Jun 20, 2003 8:50 am   Post subject: Request - Can someone post a example of case selection?

If I am correct case selection has to do with if statements right?
well thank you to whoever posts an example.
Sponsor
Sponsor
Sponsor
sponsor
Andy




PostPosted: Fri Jun 20, 2003 9:47 am   Post subject: (No subject)

ya ur rite, its a simple way to do if statements
krishon




PostPosted: Fri Jun 20, 2003 9:53 am   Post subject: (No subject)

yah..for example

code:

var char : string

put "Enter a letter grade."
get char

case char of:

 label "A"
   put "Good job"
 label "B"
   put "Nice work, your almost there."
 label "C"
   put "That's ok, try harder."
 label "D"
   put "You have to get your act into gear quick."
 label "F"
   put "Your a failure."
 label ""
   put "You entered an invalid grade, try again."
end case

its somethin like this, i forgot the format cuz i haven't used it in a while
Andy




PostPosted: Fri Jun 20, 2003 9:56 am   Post subject: (No subject)

that looks like Ti 83+ plus programming
krishon




PostPosted: Fri Jun 20, 2003 9:57 am   Post subject: (No subject)

lol, TI 83+ programming is much worse...god it takes so long just to do a stupid quadratic formula program.
Andy




PostPosted: Wed Jun 25, 2003 11:43 am   Post subject: (No subject)

no it doesn't... making a quadratic program is easy, making a factoring program takes a long time
naoki




PostPosted: Fri Jun 27, 2003 11:09 pm   Post subject: (No subject)

case still sucks cuz it's getch. i'd prefer input.keydown myself

case is sorta easier 2 work with
AsianSensation




PostPosted: Sat Jun 28, 2003 9:59 am   Post subject: (No subject)

naoki wrote:
case still sucks cuz it's getch. i'd prefer input.keydown myself


????????????
case = getch?
????????????

I always thought case was an alternate if thingie.
Sponsor
Sponsor
Sponsor
sponsor
rizzix




PostPosted: Sat Jun 28, 2003 10:32 am   Post subject: (No subject)

it is an alternate, but _restricted_, if statement syntax.
just a cosmetic feature of the language.
AsianSensation




PostPosted: Sat Jun 28, 2003 10:42 am   Post subject: (No subject)

so why is case used if it is more restricted, and therefore, offers less options then if? Does it compile quicker or something? Or is it just more user friendly? (but if/then is very user friendly....I don't see how you can get more simpler by using case....)
SilverSprite




PostPosted: Sat Jun 28, 2003 12:18 pm   Post subject: (No subject)

why do they have more than one type of operating system? its all about preference
naoki




PostPosted: Sat Jun 28, 2003 1:36 pm   Post subject: (No subject)

get char

case char of:

label "A"
put "Good job"


that's basically like getch in a sense (but more towards if statements).
Catalyst




PostPosted: Sat Jun 28, 2003 2:01 pm   Post subject: (No subject)

it isnt like getch, its a basic language construct altho everything it does can be done using ifs and elsifs (or just ifs and elses for that matter)
PaddyLong




PostPosted: Sat Jun 28, 2003 2:25 pm   Post subject: (No subject)

they are also very helpful in languages like Java where you don't have any elseif statement... just if and else...

so like you could have (not using java syntax, but the idea...)
code:

if this = a then
  do this
else
  if this = b then
    do this
  else
    if this = c then
      do this
    end if
  end if
end if


or you could just have (not using java syntax, but the idea...)
code:

case this of:
label a:
  do this
label b:
  do this
label c:
  do this
end case


so probably it's in Turing to teach you (because as we all know, turing is just for learning to program Rolling Eyes ) about them, so when you go to learn something like Java, you aren't like wtf is this??
Andy




PostPosted: Mon Jun 30, 2003 8:24 am   Post subject: (No subject)

paddylong, is there no elsif in java?
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 2  [ 20 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: