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

Username:   Password: 
 RegisterRegister   
 Class program
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
MattyGG




PostPosted: 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
Sponsor
sponsor
MattyGG




PostPosted: 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




PostPosted: 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




PostPosted: 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 Razz Guess I'll have to bug the hell outta you tomorow as well to teach you a lesson XD
beard0




PostPosted: 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"
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: