For Lab 7 you will use three parallel arrays to output the All Around winners of gymnastics competition.
INPUT
The data file you are to use is gymnasts.txt
Each line contains the following information for one gymnast:
String – name of gymnast (Store in the array for names)
Integer – age of gymnast (Store in the array for ages)
Double – score on vault (Add into sum for All Around score but do not store in an array)
Double – score on balance beam (Add into sum for All Around score but do not store in an array)
Double – score on bars (Add into sum for All Around score but do not store in an array) Double – score of floor (Add into sum for All Around score but do not store in an array)
Assume 100 is the maximum number of gymnasts.
Calculation (done in input function)
In a third one-dimensional array (type double) compute the gymnast’s All Around score by adding the scores for vault, balance beam, bars, and floor. This is best done in the input function.
In order to move the file pointer to the next gymnast you will really, really enjoy the following:
string temp;
getline(inFile,temp);//clear n or rl (Mac) before next string
OUTPUT:
Output 1: Output the name, age and All Around score for each gymnast. These should be in the following format and sorted by All Around score from high to low using selection sort. Output is to be to file
2017 USAIGC/IAGC WORLD CHAMPIONSHIPS
NAME AGE ALL AROUND
XXXXXXXXXXXXXXXXX XX XX.XXX
Sample for output 1:
2017 USAIGC/IAGC WORLD CHAMPIONSHIPS
NAME AGE ALL AROUND
Isabella Alonzo 10 38.025
Amelia Aurelio 9 37.900
etc.
Output 2: Output the name and All Around score for each gymnast that is 10 years old. Output is to be to same file as for Output 1.
Sample for output 2:
2017 USAIGC/IAGC WORLD CHAMPIONSHIPS
NAME ALL AROUND
Isabella Alonzo 38.025
Audrey Im 37.551
etc.
THEME ISSUES: one-dimensional arrays, nested loops, if statements, file input, file output
How should you do this?
STEP 1 Write main() and open file. Debug.
STEP 2 Write getdata(). At this stage there is a for loop to read each of five exercises inside a while not end of file type loop. Use debug cout statements to check that the data is being input correctly. These must be removed before final submission of project. Debug.
STEP 3 Add to getdata() computation to compute All Around score and store these values in the remaining (3rd) array of double values. Debug.
STEP 4 Write function to output heading. Debug.
STEP 5 Write output function. Debug.
STEP 6 Write function to sort using selection method. The call to this function will be placed before the output function calls. Debug.
STEP 7 Write separate function to output the names and All Around scores for all 10 yr old gymnasts.
STEP 8 “Doll up” the program documentation. Debug (just in case)
Checkpoint (alias rubric) Possible
Include name, e-mail, and lab# as comment and printed to output 3
Minimum of three (3) comments in each function
(Purpose: Pre: Post:)
Input function fills name, age and All Around score 10
Use a selection sort to sort subject numbers. This needs to be a separate function.
A separate function must be used to output the table heading ONLY 2
Separate function to output name of each gymnast, age, and All Around score sorted from highest score to least is done in a separate output function. Output must be formatted as shown. Check that output is correct. Redirect output to a file.
Separate function to output all 10-yr old gymnast’s names and All Around score is printed to the file