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

Username:   Password: 
 RegisterRegister   
 Seeking help with turing word swapping program
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Danyn




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




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




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




PostPosted: 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
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  [ 4 Posts ]
Jump to:   


Style:  
Search: