Author |
Message |
MattyGG
|
Posted: Wed Nov 24, 2004 2:19 pm Post subject: Class program |
|
|
code: |
var number : int %Will take the number of words
var lngth : int % Variable for the length of the word
var value : int % Variable to use in the loop procedure of all the characters
var character1, character2 : string %The words chars
put "How many words would you like to enter?"
get number
var words : array 1 .. number of string
for x : 1 .. number
get words (x)
end for
for i : 1 .. number
lngth := length (words (i))
value := ord (words (i) (1))
if value >= 97 and value <= 122 then
put chr (value - 32) ..
else
put chr (value) ..
end if
for j : 2 .. lngth - 1
put words (i) (j) ..
end for
value := ord (words (i) (*))
if value >= 97 and value <= 122 then
put chr (value - 32)
else
put chr (value)
end if
end for
|
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
MattyGG
|
Posted: Wed Nov 24, 2004 2:22 pm Post subject: (No subject) |
|
|
**Asks you when to enter the words**
code: |
var number : int %Will take the number of words
var lngth : int % Variable for the length of the word
var value : int % Variable to use in the loop procedure of all the characters
var character1, character2 : string %The words chars
put "How many words would you like to enter?"
get number
var words : array 1 .. number of string
for x : 1 .. number
get words (x)
end for
for i : 1 .. number
lngth := length (words (i))
value := ord (words (i) (1))
if value >= 97 and value <= 122 then
put chr (value - 32) ..
else
put chr (value) ..
end if
for j : 2 .. lngth - 1
put words (i) (j) ..
end for
value := ord (words (i) (*))
if value >= 97 and value <= 122 then
put chr (value - 32)
else
put chr (value)
end if
end for
|
|
|
|
|
|
|
Viper
|
Posted: Wed Nov 24, 2004 5:01 pm Post subject: (No subject) |
|
|
i entered yes and it out put YeS?? needs some more work and u should explain what exactly your program is doin |
|
|
|
|
|
Link_Shinigami
|
Posted: Wed Nov 24, 2004 11:13 pm Post subject: (No subject) |
|
|
Lol, that was a program we had to make in class. Capitalize the first and last letter of a string XD
Edit : Jeez Matt, learn to use the edit button Guess I'll have to bug the hell outta you tomorow as well to teach you a lesson XD |
|
|
|
|
|
beard0
|
Posted: Thu Nov 25, 2004 3:52 pm Post subject: (No subject) |
|
|
You need to account for the case in which only one letter is entered. Because you are trying to capitalize both the first and last letters, your program ends up with a two letter result, i.e. "j" -> "JJ" |
|
|
|
|
|
|