Computer Science Canada

Seeking help with turing word swapping program

Author:  Danyn [ Wed Nov 27, 2013 2:08 pm ]
Post subject:  Seeking help with turing word swapping program

What is it you are trying to achieve?
A program that gets a word and if the word starts with a capital it moves the capital to the end otherwise it does something else.


What is the problem you are having?
I get a boolean type message


Describe what you have tried to solve this problem
I've tried rewriting it but no good.

Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)


Turing:


function switch (word : string) : string
    var newWord : string
    if word (1) := "a", "e", "i", "o", "u" then
        newWord := word (2 .. *) + word (1)
    else
        newWord := word (2 .. *) + word (1) + "ing"
    end if
    result newWord
end switch

var word, swap : string
put "Enter a word"
get word : *
swap := switch (word)
put swap




Please specify what version of Turing you are using
4.1.1

Author:  Insectoid [ Wed Nov 27, 2013 2:38 pm ]
Post subject:  Re: Seeking help with turing word swapping program

code:
if word (1) := "a", "e", "i", "o", "u" then


What's wrong with this line?

Author:  Danyn [ Thu Nov 28, 2013 10:42 am ]
Post subject:  Re: Seeking help with turing word swapping program

Insectoid @ Wed Nov 27, 2013 2:38 pm wrote:
code:
if word (1) := "a", "e", "i", "o", "u" then


What's wrong with this line?


That's the line I'm having trouble with.

Author:  Raknarg [ Thu Nov 28, 2013 11:29 am ]
Post subject:  RE:Seeking help with turing word swapping program

You cannot do more than one comparison at a time. There's something called an or statement which you can use for that. Also, you cannot use ":=" for if statements, they must be "=":

Turing:

if word(1) = "a" or word(1) = "e" or... etc... then
   stuff()
end if


: