The following are the requirements of the program and all code can be written within one C++ source file for the purpose of this assignment.
1. Declare three structs to store Athlete, Event and Registration details. The struct definitions are provided in Appendix 1.
2. Write the driver code (main) and declare an array object of type Registration, assuming you can have a maximum of 20 registrations. Also, declare a pointer for this array object that you can use to access the array elements in your program.
3. In the driver, write code to display a menu for the user with the following options. Each menu item may be selected by the user using the corresponding menu number. The menu should repeat after each selection until user enters 7 for exit.
1 – Read and display registration file
2 – List all athletes by event
3 – List all athletes by country
4 – Read and display result file
5 – List medal counts by country
2 CS112 Assignment 1, 2012
6 – Display medal tally
7 – Exit
Implement each of the above menu options (1-6) in separate functions that you can call from your driver program. Below are the descriptions for each function, with the function prototypes given in Appendix 1 as a guide.
1 - The registration.txt file contains the registration ID, athlete and event details for each participating athlete. The function takes the registration array pointer (declared in step 2) as an input parameter, together with an integer size (passed as reference and used to count the number of records read in the array). The function should first ask the user to enter the complete path and filename for the input file (example C:\registration.txt), which is read and stored in the registration array using the pointer. The function should then display the contents of the input file as read in the registration array.
2 - The function takes the registration array pointer, size and an event ID (which is entered by the user within the driver) as inputs and displays the athlete ID, name and country of all athletes registered for that event.
3 - The function takes the registration array pointer, size and a country name (which is entered by the user within the driver) as inputs and displays the athlete ID, name and event name for all athletes representing that country.
4 - The results.txt file contains the event ID and top three athlete IDs (representing gold, silver and bronze winners for that event). Assume there are no ties, no multiple medal winners and the input file can contain a maximum of 20 records (results) at a time. In your driver, declare a 2-D integer array (size 20x4) that can store the contents of the input file. The function should then take this 2-D array and an integer size (passed as reference and used to count the number of records read in the array) as inputs. It should first ask user to enter the complete path and filename for the input file (example C:\result.txt), which is read and stored in the 2-D array appropriately. The function should then display the contents of the input file as read in the array.
5 - The function takes the registration array pointer, size, 2-D array, size and a country name (which is entered by the user within the driver) as inputs and displays the country name and the total number of gold, silver and bronze medals won by that country.
6 - The function takes the registration array pointer, size, 2-D array and size as inputs and lists all countries who have won a medal and display the total count of gold, silver and bronze medals for each country in some appropriate format (it is not necessary to rank or sort the countries in any particular order).
Can somebody help me with this?
I dont know where to start from. And comments as well for explanations.