Author |
Message |
KukuriChan
|
Posted: 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
|
|
|
Paul
|
Posted: 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
|
Posted: 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..
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
|
Posted: 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
|
Posted: Thu Feb 12, 2004 9:22 pm Post subject: (No subject) |
|
|
windsor eh? what school? |
|
|
|
|
|
KukuriChan
|
Posted: Thu Feb 12, 2004 9:23 pm Post subject: (No subject) |
|
|
Wow. You're four line program really worked. Thanks. ^^;; |
|
|
|
|
|
Andy
|
Posted: Thu Feb 12, 2004 9:25 pm Post subject: (No subject) |
|
|
vmss? |
|
|
|
|
|
KukuriChan
|
Posted: 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
|
|
|
Andy
|
Posted: Thu Feb 12, 2004 9:41 pm Post subject: (No subject) |
|
|
ya i'm from massey... pm me ur name |
|
|
|
|
|
|