Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 subprogram help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
mo




PostPosted: 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]
Sponsor
Sponsor
Sponsor
sponsor
ericfourfour




PostPosted: 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.
mo




PostPosted: Sat Jan 26, 2008 7:18 pm   Post subject: Re: subprogram help

how would i do that
ericfourfour




PostPosted: Sat Jan 26, 2008 7:22 pm   Post subject: RE:subprogram help

The Turing Walkthrough has tutorials for everything you will need.
mo




PostPosted: 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
ericfourfour




PostPosted: 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
Euphoracle




PostPosted: 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.
Sean




PostPosted: 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.
Sponsor
Sponsor
Sponsor
sponsor
TokenHerbz




PostPosted: 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...
ericfourfour




PostPosted: 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.
mo




PostPosted: 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
ericfourfour




PostPosted: 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
mo




PostPosted: Sun Jan 27, 2008 2:26 pm   Post subject: RE:subprogram help

thanks a lot
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 13 Posts ]
Jump to:   


Style:  
Search: