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

Username:   Password: 
 RegisterRegister   
 HELP !!!Changing numbers to the order they come in alphabet!
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
KukuriChan




PostPosted: Thu Feb 12, 2004 7:24 pm   Post subject: HELP !!!Changing numbers to the order they come in alphabet!

I'm suppose to output the letter in our alphabet that falls in that order number if it was greater than 0. I have part of it but there's always a bug in the program if a digit was two digits. Can anybody fix it?

code:

  put "Please enter a word " ..
get word
 for x : 1 .. length (word)
if strintok (word (x)) and strint (word (x)) not= 0 then
                put chr (strint (word (x)) + 96)
            else
                put "Sorry. Please try again. "
                exit
            end if
end for
Sponsor
Sponsor
Sponsor
sponsor
Paul




PostPosted: Thu Feb 12, 2004 7:27 pm   Post subject: (No subject)

What do you want? post the whole program or something, Im not sure if your trying to add 96 to the ASCII value, if that you need to use ord.
Cervantes




PostPosted: Thu Feb 12, 2004 7:57 pm   Post subject: (No subject)

code:
var num : int
put "Please enter a number " ..
get num
put chr (num + 96)


four line program.. Rolling Eyes

I'm confused though, the program you posted indicates you want to input a word and output it in numbers. the question however asks to input a number and output a word. which do you want?? the above is an answer to the question
Cervantes




PostPosted: Thu Feb 12, 2004 8:01 pm   Post subject: (No subject)

code:
var word : string
put "Please enter a word : " ..
get word
for i : 1 .. length (word)
    put ord (word (i)) - 96, "  " ..
end for



there's the code for the other way.

NOTE: that code doesn't work for capital letters.. you can code that part yourself.
Andy




PostPosted: Thu Feb 12, 2004 9:22 pm   Post subject: (No subject)

windsor eh? what school?
KukuriChan




PostPosted: Thu Feb 12, 2004 9:23 pm   Post subject: (No subject)

Wow. You're four line program really worked. Thanks. ^^;;
Andy




PostPosted: Thu Feb 12, 2004 9:25 pm   Post subject: (No subject)

vmss?
KukuriChan




PostPosted: Thu Feb 12, 2004 9:25 pm   Post subject: (No subject)

Huh? Um... I go to Massey. Should I know you? I know a lot of people here go to/went to Massey.
Sponsor
Sponsor
Sponsor
sponsor
Andy




PostPosted: Thu Feb 12, 2004 9:41 pm   Post subject: (No subject)

ya i'm from massey... pm me ur name
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  [ 9 Posts ]
Jump to:   


Style:  
Search: