Arrays in Pascal - Need Vital Help 
Author Message
 Arrays in Pascal - Need Vital Help

I currently have to design a program to read in a baseball teams records
from a file(containing players number 1-20, hits, walks, outs) and then
compute their batting average.  Their batting average along with their id
number and # of walks must then be printed out on a table.

However, for each player there are several records on the file so when
reading in the data, the program must add any previous statistics recorded
for that player # to the new ones.  This, along with designing a function
to compute their average is where my problem lies(which is of course most
of the program).

What I would really like to know is how do I read in the players info. so
that all of the records of each player are summed together.  ANd how do I
then compute the average into another array.

Your help is much appretiated, and if I can help you in the future with
anything just let me know.

Thanks again,

-Eric-



Wed, 18 Jun 1902 08:00:00 GMT  
 Arrays in Pascal - Need Vital Help

Quote:
> I currently have to design a program to read in a baseball teams records
> from a file(containing players number 1-20, hits, walks, outs) and then
> compute their batting average.  Their batting average along with their id
> number and # of walks must then be printed out on a table.

> However, for each player there are several records on the file so when
> reading in the data, the program must add any previous statistics recorded
> for that player # to the new ones.  This, along with designing a function
> to compute their average is where my problem lies(which is of course
> most of the program).
> What I would really like to know is how do I read in the players info. so
> that all of the records of each player are summed together.  ANd how do I
> then compute the average into another array.

   Assuming that each player record has something which can uniquely
identify it (a record id/number would be nice), you establish an array of
all possible players - player#1 is stored in array element #1, etc.  The
array is initialized to some "null" contents prior to reading in any
records; then, as each record Is read (into a work variable), the
id/number information is used to determine is anything for that player
has been stored: if it has, update information is _added_; if not, all
data is stored into the array element.  When the file has been read, the
array contains 1 record for each player, with all possible information.
   Why do you have multiple records for each player in the file?  Can't
you use the above process and rewrite the file from the array when the
program completes?  That way, the file need contain only one record per
player...
   As for the 2nd question, once the data in in the array, you can look
at/use the data as you like - it's all there.


Wed, 18 Jun 1902 08:00:00 GMT  
 Arrays in Pascal - Need Vital Help

Quote:

>I currently have to design a program to read in a baseball teams records
>from a file(containing players number 1-20, hits, walks, outs) and then
>compute their batting average.  Their batting average along with their id
>number and # of walks must then be printed out on a table.
>However, for each player there are several records on the file so when
>reading in the data, the program must add any previous statistics recorded
>for that player # to the new ones.  This, along with designing a function
>to compute their average is where my problem lies(which is of course most
>of the program).
>What I would really like to know is how do I read in the players info. so
>that all of the records of each player are summed together.  ANd how do I
>then compute the average into another array.

You will only ever need to keep one set of averages per player on disk
and space for two in memory.  Load the one off disk into memory, (AND
make sure that you have a variable that says how many scores this is
the average of), input the other one into memory and put the two
together proportionatly, (the maths is sooooo easy I'll leave it for
you to do).  Tada.

Matt

God didn't create the world in seven days--He goofed off for six, then pulled an all-nighter - Anon.

HomePage:  http://ds.dial.pipex.com/matt.parkins/



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Arrays in Pascal - Need Vital Help

2. Need Help in Array!

3. Urgent help with arrays needed please

4. Need help with 3D arrays.

5. Help needed understanding Parallel Arrays

6. Need help in function and array!

7. ARRAYS!! need help from all the genius

8. Sorting arrays help needed

9. Need Help with sorting through numbers in an array

10. I need to make a large array for my Computing A-Level project - can you help

11. I need to make a large array for my Computing A-Level project - can you help

12. I need help with loops and arrays!

 

 
Powered by phpBB® Forum Software