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

Username:   Password: 
 RegisterRegister   
 Converting or to our help.
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
JR




PostPosted: Tue Feb 17, 2004 6:37 pm   Post subject: Converting or to our help.

Ok so i was suppose to do a program that reads a word for example color and coverts it into canadain aka colour. now this is my program, but i get one error. when i type "color" it outputs lour. any way to fix that?
code:
var word, z : string
var i : int
var x : int := 2
put "Enter a word of your choise "
get word
i := length (word)-1
z := word (* -2) + "our"
if word (* .. i) = "or" then
    put z
end if
put z
Sponsor
Sponsor
Sponsor
sponsor
Paul




PostPosted: Tue Feb 17, 2004 6:58 pm   Post subject: (No subject)

uh, I don't get it? what are you trying to do? Use it only on Colour?
code:

var word, z : string
var i : int
var x : int := 2
put "Enter a word of your choise "
get word
i := length (word)-1
z := word (1..4)+word(*)
 
put z
JR




PostPosted: Tue Feb 17, 2004 7:09 pm   Post subject: (No subject)

no i mean you write a word. if that words end with "OR" the program needs to change it to "our". i just made colour as an example
Paul




PostPosted: Tue Feb 17, 2004 7:17 pm   Post subject: (No subject)

oh I see, you'd need something like this then
code:

var word: string
get word
if word ((length(word)-2)..*)="our" then
word:= word(1..(length(word)-2))+"r"
end if
put word
jonos




PostPosted: Tue Feb 17, 2004 9:52 pm   Post subject: (No subject)

paulbian got it backwards, this is what it should be:

var word: string
get word
if word ((length(word)-1)..*)="or" then
word:= word(1..(length(word)-1))+"ur"
end if
put word
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  [ 5 Posts ]
Jump to:   


Style:  
Search: