Computer Science Canada

arranging words alphabetically

Author:  Cloudx7 [ Sun Dec 03, 2006 7:01 pm ]
Post subject:  arranging words alphabetically

yeah, i need to make a program where i ask the user for two words, and then i put it in alphabetical order i have managed to do this by just making my variables word1, and word2, then i just put :


--------------------------------------------------------------------------------

if word1 > word2 then

put word2,"":2,word1

else

put word1,"":2, word2

end if


--------------------------------------------------------------------------------

in my program i did include the get statements and the variables... but i just put in the general idea i had for putting things alphabetically. The problem is, both words have to be either upper case, or lower case, i cant word1 as upper, and word2 as lower because lower case words are larger than upper even if the upper starts with "Z" and the lower starts with "a", my program will still display after the words are inputted, Z is before a. how do i make it so it says a before Z?

Ive skimmed through the forums, and there is a lot of stuff i didn't learn yet. for example, we didn't learn arrays yet and i doubt my teacher would think i know this sooooo yeah... but basically, im supposed to do this using if statements... my teacher gave us a hint and said use:

if word <a then

but that just determines that the word is a capital right? i can already do capitals, just need to try to compare capitals and lower case... plz help

Author:  Clayton [ Sun Dec 03, 2006 7:30 pm ]
Post subject: 

use the handy dandy Str.Upper() and/or Str.Lower() functions, what they do, is take a string parameter and put it into upper case or lower case respectively. Using this, you can call both and use either Str.Upper or Str.Lower on both of the words and sort them that way.

Author:  BenLi [ Sun Dec 03, 2006 7:53 pm ]
Post subject: 

however if your teacher hasn't told you this, he might be looking for you to go through manually and remove capitals.

Author:  Cloudx7 [ Sun Dec 03, 2006 7:55 pm ]
Post subject: 

BenLi wrote:
however if your teacher hasn't told you this, he might be looking for you to go through manually and remove capitals.


yeah, my teacher hasn't taught me whatever was metioned... how do i go through it manually??

Author:  Clayton [ Sun Dec 03, 2006 8:28 pm ]
Post subject: 

Check out the String Manipulation tutorial in the Turing Walkthrough, it has all the answers you need.


: