Your program will read two data files, set up in the same folder as was done for the first assignment. These data files are called input2a.dat and input2b.dat.
You program should have the following steps:
1. Read the team member’s family names from the first data file and store them (wherever your program design says it is best to do so). There will be 16 names. You may then close the first file.
2. Sort the above into alphabetical order.
3. Read the second data file until end-of-file. The data in this file will consist of a name followed by a number of runs (integer) followed by a character that will designate how the batman was “out”. The characters used will be b, l, c, s, r, o, and n (for notout). It will also be possible for this file to be empty.
4. For each data set, find the correct batter in your list, add in the number of runs, and record how the batter was “out” (a counter for each type of “out”).
5. Calculate the averages of all players.
6. Produce an alphabetically ordered list of the players and their performances. Use an output format that will right-justify the name.
7. Sort the list into decreasing order of batting average.
8. Produce a similar list of results to the one above.
Observation: While it is possible to complete this assignment using a number of parallel arrays, your design will be better and easier to work with, if you define your own structured type (it is best to use our naming convention of structname_t), and then have a single array of these objects. Your design will also benefit from having a number of functions. A solution that does not have well designed functions to perform major tasks, will be marked down significantly.
Output should be produced along the following guidelines:
Name should be right-justified as stated above, Number of Innings and Number of Not-Outs are 3 digit integers, Number of Runs is up to 5 digits long, average should allow for a range from 0.00 to 999.99. Use headings as appropriate to display the data as a table. E.g.
Team Batting - Alphabetical Order How Out
Name Inn NO Runs Avge B L C S R O
Beer 0 0 0 0.00 0 0 0 0 0 0
Clarke 3 0 96 32.00 0 1 2 0 0 0
Copeland 2 1 35 35.00 0 0 1 0 0 0
Note that alphabetical order does not include the leading spaces that are part of the right-justification of the output of the name.