Author |
Message |
mo
|
Posted: 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] |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
ericfourfour
|
Posted: 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. |
|
|
|
|
![](images/spacer.gif) |
mo
|
Posted: Sat Jan 26, 2008 7:18 pm Post subject: Re: subprogram help |
|
|
how would i do that |
|
|
|
|
![](images/spacer.gif) |
ericfourfour
|
Posted: Sat Jan 26, 2008 7:22 pm Post subject: RE:subprogram help |
|
|
The Turing Walkthrough has tutorials for everything you will need. |
|
|
|
|
![](images/spacer.gif) |
mo
|
Posted: 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 |
|
|
|
|
![](images/spacer.gif) |
ericfourfour
|
|
|
|
![](images/spacer.gif) |
Euphoracle
![](http://compsci.ca/v3/uploads/user_avatars/11170373664bf5f25f636f1.png)
|
Posted: 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. |
|
|
|
|
![](images/spacer.gif) |
Sean
![](http://compsci.ca/v3/uploads/user_avatars/47413941748406f441f83e.png)
|
Posted: 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. |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
TokenHerbz
![](http://compsci.ca/v3/uploads/user_avatars/717170395558e628d9452b.jpg)
|
Posted: 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... |
|
|
|
|
![](images/spacer.gif) |
ericfourfour
|
Posted: 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. |
|
|
|
|
![](images/spacer.gif) |
mo
|
Posted: 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 |
|
|
|
|
![](images/spacer.gif) |
ericfourfour
|
Posted: 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:
|
|
|
|
|
![](images/spacer.gif) |
mo
|
Posted: Sun Jan 27, 2008 2:26 pm Post subject: RE:subprogram help |
|
|
thanks a lot |
|
|
|
|
![](images/spacer.gif) |
|