Computer Science Canada

Need help!

Author:  Risen123 [ Thu Nov 08, 2012 12:50 pm ]
Post subject:  Need help!

[I have a test tommorow that is open book. I have been busy with family issues so haven't had time to study and learn all of these in class.

Questions should be fully coded, they are the following!

1.Input a word, once inputted make the word spelt vertically with a space between each letter

2.When a sentance is inputted, delete the spaces between the sentance and output it

3.Open a file and add all the numbers in the file a nd output the sum

4.Input a word and space it out in between letters

5.Take all the a's and turn them into z's in the sentance

6.Go through a text file and count how many numbers there are

Author:  Tony [ Thu Nov 08, 2012 1:04 pm ]
Post subject:  RE:Need help!

Thx for sharing!

Author:  Risen123 [ Thu Nov 08, 2012 3:34 pm ]
Post subject:  RE:Need help!

Somebody help please!

Author:  evildaddy911 [ Thu Nov 08, 2012 3:58 pm ]
Post subject:  RE:Need help!

thank you for telling us this. Shall I assume you want help with this?

What the teacher wants you to do is basically string manipulation. string manipulation generally goes as such:
Turing:

for i : 1 .. length (string)
    %
    %
end for


One thing you need to keep in mind is that strings are essentially arrays, each element being one character.

Author:  Risen123 [ Thu Nov 08, 2012 4:16 pm ]
Post subject:  RE:Need help!

It would help if I could get an example of a few of them so I know what I'm looking for, I literally missed 3 weeks of school because my parents were divorcing and I went into clinical depression

Please anyone!

Author:  Tony [ Thu Nov 08, 2012 4:40 pm ]
Post subject:  RE:Need help!

a good example would be
Turing:

var word : string
put "enter a word"
get word

for i : 0 .. length(word) - 1
   put "letter in position ", i, " is: ", word(i)
end for

Author:  Risen123 [ Thu Nov 08, 2012 5:02 pm ]
Post subject:  RE:Need help!

#1, #3, #6 if answered would be amazing!

Author:  [Gandalf] [ Thu Nov 08, 2012 5:29 pm ]
Post subject:  Re: Need help!

We won't answer your test questions for you, or do your homework for you. Although, if you search through these forums I'm sure you'll find code very similar to what you need, and probably learn a thing or two. You can start with the Turing Walkthrough.

Author:  Tony [ Thu Nov 08, 2012 5:32 pm ]
Post subject:  RE:Need help!

My example is really really close to what #1 is asking for. What part is it missing? How do you think that could be solved?

#3,6 are presumably difficult because they deal with files. The Turing Walkthrough is your crash course through everything Turing, which links you to a File Tutorial -- http://compsci.ca/v3/viewtopic.php?t=12972 You will only need "put" and "get" modes of access. Don't worry about "read" or "write".

Author:  Risen123 [ Thu Nov 08, 2012 6:36 pm ]
Post subject:  RE:Need help!

I have #1 but it makes the text backwards! how do you fix that?


var line : string

% Input a string from the user

locate (1, 1)

put "Enter a phrase. " ..
get line : *

% Display sentence with spaces between them

for decreasing i : length (line) .. 1
put line (i), " " ..
end for

Author:  Insectoid [ Thu Nov 08, 2012 6:40 pm ]
Post subject:  RE:Need help!

code:
for decreasing i : length (line) .. 1


Hmm, I wonder what the problem could possibly be. Can't seem to find anywhere! I thought it would be painfully obvious, but evidently I was wrong.

Author:  Risen123 [ Thu Nov 08, 2012 6:42 pm ]
Post subject:  RE:Need help!

I don't know how to fix it! I went complete dummy on it Sad

I tried making it increasing, didn't work

how do I fix it? Surprised

Author:  Aange10 [ Thu Nov 08, 2012 7:01 pm ]
Post subject:  RE:Need help!

Listen to what they're telling you. The Turing Walkthrough has your answer.

http://compsci.ca/v3/viewtopic.php?t=3678

Author:  Risen123 [ Thu Nov 08, 2012 7:07 pm ]
Post subject:  RE:Need help!

I looked through the guide, I changed decreasing to counter and it says i needs to be declared!

I'm so confused!

Author:  Risen123 [ Thu Nov 08, 2012 7:10 pm ]
Post subject:  RE:Need help!

Ok I got #1 and #4, thank you!

Author:  Insectoid [ Thu Nov 08, 2012 7:28 pm ]
Post subject:  RE:Need help!

#2: Output the letters as normal. If the letter is a space, don't.

#3:literally just turn the question into code. It can't really be simplified further.

#5: Same as number 2, except instead of looking for spaces, look for As, and instead of not outputting them, output a Z.

#6: Same as number 2, except instead of looking for spaces, look for numbers, and instead of not outputting them, increment a counter.

Author:  Tony [ Fri Nov 09, 2012 1:04 am ]
Post subject:  Re: RE:Need help!

Risen123 @ Thu Nov 08, 2012 6:36 pm wrote:

for decreasing i : length (line) .. 1

So... where did you copy this line of code from?


: