
-----------------------------------
mo
Sat Jan 26, 2008 6:49 pm

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]

-----------------------------------
ericfourfour
Sat Jan 26, 2008 7:16 pm

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.

-----------------------------------
mo
Sat Jan 26, 2008 7:18 pm

Re: subprogram help
-----------------------------------
how would i do that

-----------------------------------
ericfourfour
Sat Jan 26, 2008 7:22 pm

RE:subprogram help
-----------------------------------
The Turing Walkthrough has tutorials for everything you will need.

-----------------------------------
mo
Sat Jan 26, 2008 7:27 pm

Re: subprogram help
-----------------------------------
cant find it can u start it for me and clarify it for me

-----------------------------------
ericfourfour
Sat Jan 26, 2008 8:18 pm

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

-----------------------------------
Euphoracle
Sun Jan 27, 2008 3:42 am

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.

-----------------------------------
Sean
Sun Jan 27, 2008 10:08 am

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.

-----------------------------------
TokenHerbz
Sun Jan 27, 2008 12:44 pm

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...

-----------------------------------
ericfourfour
Sun Jan 27, 2008 1:10 pm

RE:subprogram help
-----------------------------------
You guys all basically repeated question two of the Turing FAQ which I linked to.

-----------------------------------
mo
Sun Jan 27, 2008 2:06 pm

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

-----------------------------------
ericfourfour
Sun Jan 27, 2008 2:21 pm

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:
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:
close : stream

-----------------------------------
mo
Sun Jan 27, 2008 2:26 pm

RE:subprogram help
-----------------------------------
thanks a lot
