Merging and sorting

I am new to C++ but I have a basic understanding of most of the concepts. My assignment is to create a program that manages data for a basketball team.
Here are the specifics of the assignment.

I must start with a file named "roster.txt" that contains records of the following format.
uniformNumber firstName lastName games points
(example) 20 Omar Rialto 12 289

I need to update the roster.txt file by processing the records in a file called
updates.txt

Updates.txt contains records of the following format:
1) Each record begins with an update type: A (for add a player), R (for remove a
player), or U (for update a player’s information)

2) If the update type is an A, the rest of the record will be a uniform number, a first name, a last name, a number of games, and a number of points. This
update type implies we should add this player to the roster.

3) If the update type is an R, the rest of the record will be a uniform number
only. This update type implies we should remove this player from the roster.

4) If the update type is a U, the rest of the record will be a uniform number and a number of points. This update type implies we should modify the record of
the player with this uniform number by increasing his number of games by 1
and his number of points by the value indicated.

Assume that the file update.txt is sorted by number in ascending order. However,
the file roster.txt will initially be sorted by last name and must be sorted by number in ascending order before processing the updates. Assume that there are no duplicate numbers in either file.

How can errors occur?
1) If we try to add a player number that is already on the roster, that is an
error.

2) If we try to remove a player number that is not on the roster, that is an error.

3) If we try to update a player number that is not on the roster, that is an error.

All errors should cause an appropriate error message to be sent to an output file named errors.txt.

Once all updates are processed, output to a file named starters.txt the complete
records of the five players with the highest scoring averages
Last edited on
Topic archived. No new replies allowed.