
-----------------------------------
gayden
Thu Feb 19, 2015 10:41 am

How do I get turing to repeat a string a certain amount of times?
-----------------------------------
So, I have an assignment in a beginner's compsci class where we have to write a program that asks the user to enter a word, and then the program will repeat the word for as many times as it has characters.

I know I need to use length (x) to get the number of times, but how do I get it to loop x times? Or how do I use a statement such as for i : 1 .. length(x) to output a string instead of numbers?

-----------------------------------
Tony
Thu Feb 19, 2015 1:26 pm

Re: How do I get turing to repeat a string a certain amount of times?
-----------------------------------
how do I use a statement such as for i : 1 .. length(x) to output a string instead of numbers?
Sounds like you are already familiar with all the required pieces, and just need to give it a try. How do you output numbers that you've mentioned above?

-----------------------------------
gayden
Fri Feb 20, 2015 12:17 am

Re: How do I get turing to repeat a string a certain amount of times?
-----------------------------------
how do I use a statement such as for i : 1 .. length(x) to output a string instead of numbers?
Sounds like you are already familiar with all the required pieces, and just need to give it a try. How do you output numbers that you've mentioned above?
I believe I am, but I'm not sure how to actually utilize it.

And what do you mean by that? Like, how do you output a number you mentioned earlier in the program?
(if so, use a variable, get x, put x, etc.)

-----------------------------------
Insectoid
Fri Feb 20, 2015 2:33 am

RE:How do I get turing to repeat a string a certain amount of times?
-----------------------------------
Everything inside a for loop executes a certain number of times. You've got all the pieces already, you just need to put them together. We really can't give you any more hints without giving away the entire answer.

-----------------------------------
gayden
Fri Feb 20, 2015 9:48 am

Re: RE:How do I get turing to repeat a string a certain amount of times?
-----------------------------------
Everything inside a for loop executes a certain number of times. You've got all the pieces already, you just need to put them together. We really can't give you any more hints without giving away the entire answer.
I think I've got it, this is what I put:
[code]var word : string
put "Please enter a word: " ..
get word
for i : 1 .. length (word)
    put word
end for
[/code]

-----------------------------------
Tony
Fri Feb 20, 2015 1:34 pm

RE:How do I get turing to repeat a string a certain amount of times?
-----------------------------------
Looks good to me.
