Computer Science Canada

subprogram help

Author:  mo [ Sat Jan 26, 2008 6:49 pm ]
Post subject:  subprogram help

can anyone help me make a Turing program that accepts exactly 15 students marks in (as a percent) and outputs only those marks that are equal to or above the average (mean) mark.

The marks, from a text file (in.txt), are retrieved and populated inside a subprogram that must have the signature[color=black][/color][size=12][/size][font=Times New Roman][/font]

Author:  ericfourfour [ Sat Jan 26, 2008 7:16 pm ]
Post subject:  RE:subprogram help

You should think of a few things:

How you are going to get and store all of the marks.
How you are going to find the average of all of the marks.
How you are going to find the marks that are above the average.

For this you are going to need basic file input, arrays, basic arithmetic, for loops and if structures.

Author:  mo [ Sat Jan 26, 2008 7:18 pm ]
Post subject:  Re: subprogram help

how would i do that

Author:  ericfourfour [ Sat Jan 26, 2008 7:22 pm ]
Post subject:  RE:subprogram help

The Turing Walkthrough has tutorials for everything you will need.

Author:  mo [ Sat Jan 26, 2008 7:27 pm ]
Post subject:  Re: subprogram help

cant find it can u start it for me and clarify it for me

Author:  ericfourfour [ Sat Jan 26, 2008 8:18 pm ]
Post subject:  Re: subprogram help

I'm not really sure why you are having so much trouble finding the Tutorials.

Here's the basics: http://compsci.ca/v3/viewtopic.php?t=9634
Here's if structures: http://compsci.ca/v3/viewtopic.php?t=14656
Here's for loops: http://compsci.ca/v3/viewtopic.php?t=3678
Here's file input: http://compsci.ca/v3/viewtopic.php?t=12972
Here's arrays: http://compsci.ca/v3/viewtopic.php?t=14333

You might also want to refer to question two of the Turing FAQ: http://compsci.ca/v3/viewtopic.php?t=12610

Author:  Euphoracle [ Sun Jan 27, 2008 3:42 am ]
Post subject:  RE:subprogram help

Just to clarify, if you're seeking someone to write this for you, you've come to the wrong place. That's the impression I'm getting from your posts, sorry if I'm mistaken.

Author:  Sean [ Sun Jan 27, 2008 10:08 am ]
Post subject:  Re: subprogram help

I too see this, and am disapproving.

Secondly, all the stuff you need is one the Tutorials, you probably didn't even look, just to get someone to write it for you. Which will not happen.

This topic will soon be locked if you keep it up.

Author:  TokenHerbz [ Sun Jan 27, 2008 12:44 pm ]
Post subject:  RE:subprogram help

Write your own code to the best of your ability, then share it with us if you still seek help, And from there we will help you correct it...

Author:  ericfourfour [ Sun Jan 27, 2008 1:10 pm ]
Post subject:  RE:subprogram help

You guys all basically repeated question two of the Turing FAQ which I linked to.

Author:  mo [ Sun Jan 27, 2008 2:06 pm ]
Post subject:  Re: subprogram help

var marks: flexible array 1..1 of string
var stream:int
open: stream,"in.txt",get
loop
exit when eof(marks)
get: stream, marks(upper(marks))
new marks, upper(marks)+1
end loop

im stuck i dont know how to get average to pop up to "in.txt" file

Author:  ericfourfour [ Sun Jan 27, 2008 2:21 pm ]
Post subject:  Re: subprogram help

It should be eof (stream) instead of eof (marks).

With a for loop you can iterate through all of the elements in the array:
Turing:
for i : 1 .. upper (marks)
    put marks (i)
end for


To find the average you need to get the sum of all of the marks and divide by the number of marks. Figure out a way to use variables and the for loop to calculate the average.

Remember to close your file when you are done with it:
Turing:
close : stream

Author:  mo [ Sun Jan 27, 2008 2:26 pm ]
Post subject:  RE:subprogram help

thanks a lot


: