/*
Lab3A
*/
#include <iostream>
#include <iomanip>
#include <string>
usingnamespace std;
void main()
{
// declaration and initialization
string diverName, city;
double score, total_score, final_score = 0;
double difficulty;
double highest, lowest, overall;
char process_diver;
int judge_ctr, num_divers = 0;
// heading
cout << "Report to the media\n";
cout << "Event: Diving competition\n\n";
// formatting
cout << fixed << showpoint << setprecision(2);
do
{
cout << "Enter the diver's name: ";
getline(cin, diverName);
cout << "Enter the diver's city: ";
getline(cin, city);
highest = -1;
lowest = 11;
total_score = 0;
judge_ctr = 1;
do
{
cout << "Enter the score given by judge #"
<< judge_ctr << ": ";
cin >> score;
if (score <= 0 || score >= 11)
{
cout << "Values must be between 0 and 10.";
cout << "Enter the score given by judge # " << judge_ctr << ": ";
cin >> score; }
total_score += score;
judge_ctr++;
}
while (judge_ctr <= 5);
cout << "Enter between 1.0 and 1.67 inclusive." << endl;
cout << "What was the degree of difficulty? ";
cin >> difficulty;
if (difficulty <= 0.9 || difficulty >= 1.68)
{
cout << "Invalid range. Choose between 1.0 and 1.67";
cout << "What was the degree of difficulty? ";
cin >> difficulty;
}
overall = (total_score - lowest - highest) / 3 * difficulty;
cout << "Diver: " << diverName << ", City: " << city<< endl;
final_score = final_score + overall;
num_divers = num_divers + 1;
cout << "Overall score was " << final_score <<"."<< endl;
cout << "\nDo you want to process another diver (Y/N)? ";
cin >> process_diver;
process_diver = toupper(process_diver);
cin.ignore(50, '\n');
}
while (process_diver == 'Y' || process_diver =='y');
cout << "EVENT SUMMARY\n";
cout << "Number of divers participating: " << num_divers << endl;
cout << "Average score of all divers: "<< final_score / num_divers << endl;
}
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 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
:
The event summary never shows up, or it automatically exits before I can see it. Everything else seems to work. I know it's something simple, but my eyes just can't see it.