Question
C++ Scoring a Diving Competition The names of divers and their scores for a dive are stored in a file called DIV1.txt . Each diver's
C++ Scoring a Diving Competition
The names of divers and their scores for a dive are stored in a file called DIV1.txt . Each diver's name is stored on a line followed by that divers data for one dive. The data contains the difficulty factor of the dive and a score from each of 5 judges. Compute each divers total score by throwing out his/her low and high scores (do not change the order of the scores), averaging the remaining three scores, and then multiplying this average by the difficulty factor. Output each diver's name, his/her scores, and the total score for the dive arranged from the diver with the highest score to the lowest. Output is to be directed to a file.
The contents of DIV1.txt is to be:
KNIFE JACK 1.3 6.0 5.1 6.3 5.9 6.5
WILLIAMSON FLIP A 1.4 3.5 4.1 4.7 7.2 3.8
SOMMER TODD 1.2 8.0 9.1 8.1 9.3 9.0
SWAN MIKE 1.1 4.3 2.1 9.9 6.2 7.0
Input: Assume a maximum of 50 divers. Name of diver, difficulty factor, array for scores, and the total score for the dive should be members of a structure. The structure should contain a nested structure for difficulty factor, array of scores, and total score for dive. Each divers structure needs to be an element of an array of structures.
Processes: Computation of total score is to be handled in a separate function. A separate function should perform the sort using the bubble sort algorithm. Output: Use a separate function for output. Output is to be directed to a file.
Theme Issues: Array of structures, Sorting.
Requirements:
- Function main() may contain only declarations, function calls to your declared functions, and comments.
- Function to input all diver information and store this in an array of structures. The number of judges needs to be a #define and the code should not depend on it being the value of 5.
- Function to calculate the total score for each diver. This may be called either from main() or from the input function.
- Function to sort by total score from highest to lowest implementing the bubble sort.
- Function to output (and only one output function where all the output occurs).
Thank you.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started