Your State Dive Association presently scores its diving competitions with pencil
ID: 3632769 • Letter: Y
Question
Your State Dive Association presently scores its diving competitions with pencil and paper. They would like for you to design and develop a Dive Program in C++.The paper forms that they presently use have the following:
Diver’s Name, City
JudgeScore1 - The scores entered are from 0 to 10.
JudgeScore2
JudgeScore3
JudgeScore4
JudgeScore5
DegreeOfDifficulty - This is assigned once for each diver.
OverAllScore - The overall score is the individual diver’s scores totaled and then divided by the degree of difficulty. The highest and lowest scores are removed as they are often skewed entries. Total the three scores left, divide them by 3, and then multiply that by the DegreeOfDifficulty. The degree of difficulty ranges from 1.00 to 1.67.
Display the diver's information and overall score.
When the competition is complete, there is a summary report created that lists the total number of divers and the average of the overall scores.
Lab hints: When writing this lab, use nested loops. A nested loop is when one loop is completely contained in another loop. In an inner loop, you will read the five scores one at a time. Every time you read the score (in the loop), you will compare the score to the highest so far and also to the lowest so far so you can determine the highest and lowest scores, in addition to adding the scores up one at a time.
You also need to have your program process multiple divers. Put this in an outer loop. After you process the information for one diver, prompt the user if she/he wants to process another diver. Allow the user to type either a “Y” or “y” to enter another diver's information; otherwise, exit the loop. Write an event summary by calculating and displaying the average score for all divers and the total number of divers participating.
Garbage in Garbage Out (GIGO): The data being entered by the user needs to be validated. Scores by judges may range between 0 and 10. If the user enters an invalid score, display an error message, and prompt for the score again. Keep doing this until the user enters the score correctly. The degree of difficulty may range from 1.00 to 1.67.
Sample output from program
Report to the media
Event: Diving competition
Enter the diver's name: Sue Jones
Enter the diver's city: Dallas
Enter the score given by judge #1: 45
Invalid score - Please reenter (Valid Range: 0 - 10)
Enter the score given by judge #1: 3
Enter the score given by judge #2: 4.5
Enter the score given by judge #3: 6.7
Enter the score given by judge #4: 89
Invalid score - Please reenter (Valid Range: 0 - 10)
Enter the score given by judge #4: 8
Enter the score given by judge #5: 9.2
What was the degree of difficulty? 1.9
Invalid degree of difficulty - Please reenter (Valid Range: 1 - 1.67)
What was the degree of difficulty? 2
Invalid degree of difficulty - Please reenter (Valid Range: 1 - 1.67)
What was the degree of difficulty? 1.2
Diver: Sue Jones, City: Dallas
Overall score was 7.68
Do you want to process another diver (Y/N)? y
Enter the diver's name: Dave Smith
Enter the diver's city: Houston
Enter the score given by judge #1: 5.7
Enter the score given by judge #2: 6.8
Enter the score given by judge #3: 7.6
Enter the score given by judge #4: 8.7
Enter the score given by judge #5: 6.7
What was the degree of difficulty? 1.1
Diver: Dave Smith, City: Houston
Overall score was 7.74
Do you want to process another diver (Y/N)? n
EVENT SUMMARY
Number of divers participating: 2
Average score of all divers: 7.71
Press any key to continue . . .
Step 2: Processing Logic
Using the pseudocode below, write the code that will meet the requirements.
Write report heading
Loop as long as there are divers to process
Input diver's name and city
Initialize highest score, lowest score and total score
Using a do-while loop input the 5 judge's scores
Validate the score to ensure it is between 0 and 10
Add score to total
Determine highest and lowest scores
Input and validate the degree of difficulty
Calculate the overall diver's score
Display the diver's information and overall score
Add diver's overall score to the final score
Add 1 to the number of divers
Prompt the user if she wants to process another diver
End-Loop
Calculate the average score for all divers
Display the number of divers and the average score for all divers
Explanation / Answer
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
int main()
{
//report heading
cout << "Report to the media" << endl;
cout << "Event: Diving competition" << endl;
// variables needed
string name, city;
double score[5], deg_diff, high_score, lowest_score;
double total_score, overall_score, overall_avg = 0.0;
int numOfDivers = 0;
char choise = 'Y';
do{ // reads player name
cout << " Enter the diver's name: ";
getline(cin, name, ' ');
// reads player city
cout << "Enter the diver's city: ";
getline(cin, city, ' ');
//initializing high, low and total scores
high_score = 0;
lowest_score = 10;
total_score = 0;
// loop 5 times to read five judges score
for(int i = 0; i < 5; i++)
{
cout << "Enter score given by judge #" << i+1 <<": ";
cin >> score[i];
// validating user input
while(score[i] < 0 || score[i] > 10)
{
cout << "Invalid score - Please reenter(Valid Range: 0-10)" << endl;
cout << "Enter score given by judge #" << i <<": ";
cin >> score[i];
}
// updating high, low and total scores
if( score[i] > high_score)
high_score = score[i];
if( score[i] < lowest_score)
lowest_score = score[i];
total_score += score[i];
}
// reading degree of difficulty
cout << "What was the degree of difficulty? ";
cin >> deg_diff;
// validating degree of difficulty
while (deg_diff < 1 || deg_diff > 1.67)
{
cout << "Invalid degree of difficulty - Please reenter(Valid Range: 1-1.67) " << endl;
cout << "What was the degree of difficulty? ";
cin >> deg_diff;
}
// calculating overall score as gievn in program description
overall_score = ( ( total_score - lowest_score - high_score) / 3.0 ) * deg_diff;
// displaying player name, city and overall score to the console
cout << " Diver: " << name << ", City: " << city << endl;
cout << "Overall score was " << fixed << setprecision(2) << overall_score << endl;
// ask for another entry
cout << " Do you want to process another driver (Y/N)? ";
cin >> choise;
cin.ignore();
// updating number of divers and overall average
numOfDivers++;
overall_avg += overall_score;
}while(choise != 'n' && choise != 'N');
// displaying event summary
cout << " EVENT SUMMARRY" << endl;
cout << "Number.of divers participating: " << numOfDivers << endl;
cout << "Average score of all divers: " << fixed << setprecision(2) << (overall_avg / numOfDivers) << endl;
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.