Question: C++ Help with nested loops It will work best with a nested for loop.) Write a program that calculates the total and average points for
C++ Help with nested loops
It will work best with a nested for loop.) Write a program that calculates the total and average points for each member of a gymnastics sports team. The gymnasts receive an integer score that ranges from 0 to 10, inclusive for each event. All members of the team are required to compete in all events at a competition. Also calculate the total and average for the entire team. Allow the user to calculate the stats on as many teams as desired.
Prompt the user for the number of members on the team and the number of events competed in. Do not allow the user to enter a negative amount for either of these values. If a negative value is entered, display an error message and prompt for re-entry for that value.
b.For each member of the team, allow the user to enter the gymnasts name and the points earned by that member for each event. Prompt for the points earned by each gymnast using their name. Do not let the user enter an invalid score. (The score must be an integer in the range of 0 to 10, inclusive.) If an invalid score is entered, display an error message and prompt for re-entry.
For each gymnast on the team, display their name, total points, and average to a tenth of a decimal.
After processing each member of the team, display the teams total points and average per event to a tenth of a decimal.
Sample I/O:
*************************************************
* This program calculates the total and average *
* points for each member of a gymnastics team. *
* The team's total and average points are also calculated. *
*************************************************
Please enter the number of gymnasts on the team: ? 3
Please enter the number of events the team competed in: ? 4
Enter gymnast 1's name: ? Sue Mills
Enter the points earned by Sue Mills for each event.
Event 1: ? 9
Event 2: ? 17
**** ERROR INVALID SCORE PLEASE RE-ENTER ****
Event 2: ? 77
**** ERROR INVALID SCORE PLEASE RE-ENTER ****
Event 2: ? 7
Event 3: ? 6
Event 4: ? 8
Sue Mills:
Total Points: 30
Average Points: 7.5
Enter gymnast 2's name: ? Lisa Jones
Enter the points earned by Lisa Jones for each event:
Event 1: ? 6
Event 2: ? 8
Event 3: ? 7
Event 4: ? 5
Lisa Jones:
Total Points: 26
Average Points: 6.5
Enter gymnast 3's name: ? Mary Smith
Enter the points earned by Mary Smith for each event:
Event 1: ? 9
Event 2: ? 8
Event 3: ? 6
Event 4: ? 8
Mary Smith:
Total Points: 31
Average Points: 7.8
Total Team Points: 87
Average Team Points per Event: 7.3
Would you like to calculate the stats on another team? Y or N
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
