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

Username:   Password: 
 RegisterRegister   
 im totally lost
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
chipmiester




PostPosted: Thu Nov 10, 2005 7:41 pm   Post subject: im totally lost

ok i have no clue as to how i would do this. how would i be able to sort names entered alphabetically? example: if i enter compsci it would put it on a list of a-h names only and if i enter zebra it will go on the second list of i-z. all i need to know would be how to sort them. i can program it to accept user input and the if...end if thing with elsif. (thats what were learning at the moment) so will anyone be able to help me sort inputted names with the if..end if command (with elsif)
Sponsor
Sponsor
Sponsor
sponsor
iker




PostPosted: Thu Nov 10, 2005 8:04 pm   Post subject: (No subject)

You should know not to help for school work on this site, but its a very simple program anyways...

code:

var word : string
var ah,iz : int
loop
    put "enter a word, exit with 1"
    get word
    if word = '1' then
        exit
    elsif word <i then
        ah+= word + " "
    elsif word >h then
        iz += word + " "
    end if
end loop

this will get all of your words, then output them in the order that you gave them Very Happy
chipmiester




PostPosted: Thu Nov 10, 2005 8:12 pm   Post subject: (No subject)

lol i know that does that but how do i sort by alphabet (one list A-H other one I-Z) we were not taught this yet
Tony




PostPosted: Thu Nov 10, 2005 10:38 pm   Post subject: (No subject)

you can compare words to each other
Turing:

put "compsci" < "i"

that should result in true, which you could use in an if statement to determine that your word ("compsci" in this case) comes before letter "i" alphabetically.

watch out for upper case, those letters have different values. You should make sure that both words are of the same case before comparing, so a function such as toupper() would be of use.
[Gandalf]




PostPosted: Thu Nov 10, 2005 10:43 pm   Post subject: (No subject)

No need to remake what you already have... Str.Upper() or Str.Lower()
do_pete




PostPosted: Fri Nov 11, 2005 11:20 am   Post subject: (No subject)

yeah bu some older versions of Turing don't have Str.Upper or Str.Lower
xtreemboarder




PostPosted: Wed Nov 16, 2005 1:56 am   Post subject: (No subject)

iker wrote:
You should know not to help for school work on this site, but its a very simple program anyways...

code:

var word : string
var ah,iz : int
loop
    put "enter a word, exit with 1"
    get word
    if word = '1' then
        exit
    elsif word <i then
        ah+= word + " "
    elsif word >h then
        iz += word + " "
    end if
end loop

this will get all of your words, then output them in the order that you gave them Very Happy


program wouldnt work bud. cant assign an int to equal a string. Wink
iker




PostPosted: Wed Nov 16, 2005 5:14 pm   Post subject: (No subject)

sorry, it should say string, but anyways, its a miner error from days ago..., and it wasn't even what he wanted...
Sponsor
Sponsor
Sponsor
sponsor
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  [ 8 Posts ]
Jump to:   


Style:  
Search: