Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A tele match event has been held in a primary school. Three teams are allowed to participate in this match, with each team consisting of

image text in transcribedimage text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

A tele match event has been held in a primary school. Three teams are allowed to participate in this match, with each team consisting of four participants. Five (5) events were contested, namely E1, E2, E3, E4 and E5. Table 1 and Figure 1 show the scores that have been collected by each team for the five events. Write a C++ program which can assist the tele match committee to determine the winner for these events. Your program should be able to do the following tasks: a) The program will read input data: team ID, participant ID and scores for the five events namely E1, E2, E3, E4 and E5 from an input file named "input.txt" into an array marks [12] [7] with int type. (*** Array can be 2-dimensional or 3-dimensional). b) The program must be able to notify the user if the input file cannot be opened (failed to open) with proper prompt. The example for user notification where the file fails to open is shown in Figure 2. c) Calculate the total score for each participant. d) Calculate the total score for each team. Table 1: Collected scores Team ID Participant ID E1 E1 E2 E3 E2 E3 E4 E5 1001 10 5 8 10 6 1002 8 7 7 10 7 9 1 1003 7 10 10 6 10 1004 10 | 10 8 7 7 2001 7 8 10 9 10 2002 10 8 7 8 10 2 2003 8 6 8 8 10 2004 7 8 8 8 8 3001 10 9 10 10 10 3002 8 7 8 8 8 3 3003 7 8 9 10 6 3004 8 6 8 7 7 1 1001 10 5 8 10 6 1 1002 8 7 10 7 9 1 1003 7 10 10 6 10 1 1004 10 10 8 7 7 2 2001 7 8 10 9 10 2 2002 10 8 7 8 10 2 2003 8 6 8 8 10 2 2004 7 8 8 8 8 3 3001 10 9 10 10 10 3 3002 8 7 8 8 8 3 3003 7 8 9 10 6 3 3004 8 6 8 7 Figure 1: Input file named "input.txt" Sorry, input file does not exist! Press any key to continue Figure 2: Example for user notification in case file fails to open Table 2: Description for functions Function Description displayLine (). To display lines using the 52 characters of `-?. The function should use loop to display the line. findIndWinner () To determine the winner for individual category (selected based on the highest total score that collected by the participants). The function should accept the array for a total score of each participant as one of its argument. findTeamWinner (). To determine the winner of group category (selected based on the highest total score that collected by the teams). The function should accept the array for a total score of each team as one of its argument. e) Besides the main() function, the program needs to define three other functions as described in Table 2. Use appropriate argument (if necessary) for each function. Id E1 E2 E3 E4 E5 Total TEAM 1 1001 1002 1003 1004 TOTAL 10 8 7 10 5 7 10 10 8 10 10 8 10 7 6 7 6 9 10 7 39 41 43 42 165 7 TEAM 2 2001 2002 2003 2004 TOTAL 10 8 8 6 8 10 7 8 8 9 8 8 8 10 10 10 8 8 7 44 43 40 39 166 TEAM 3 3001 3002 3003 3004 TOTAL 10 8 7 8 9 7 8 6 10 8 9 8 10 8 10 7 10 8 6 7 49 39 40 36 164 Winner for Individual Category: 3001 (Team 3) Winner for Group Category: Team 2 (Score = 166) Press any key to continue Figure 3: Example of output f) The program needs to print out the following information. Figure 3 shows the example, run of the successful program. i. The team ID. ii. The participant ID. iii. The scores for the five events, E1, E2, E3, E4 and E5 for each participant. iv. The total score for each participant. The total score for each team. vi. The winner for individual category (selected based on the highest total score that collected by the participants). vii. The winner for group category (selected based on the highest total score that collected by the teams). viii. Display all of these output in an output file name "output.txt" well. V

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MongoDB Applied Design Patterns Practical Use Cases With The Leading NoSQL Database

Authors: Rick Copeland

1st Edition

1449340040, 978-1449340049

Students also viewed these Databases questions

Question

The histogram above was created with the following code: sdob1

Answered: 1 week ago