Can anyone give me advice or guidance with this C++ program, i keep getting errors, and I'm not sure why? Thanks!?
I have all of the code written up and ill provide it below here, but the problem i am having is the values are not calculating properly and i cant seem to figure it out, can someone please help me! Please read this whole page because ill list my code, then the pseudocode of what it is supposed to do, and then below that i will enter the problem i am having when trying to run the code. Thanks!
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;
}
}
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;
system("pause");
return EXIT_SUCCESS;
}
My pseudocode;
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
What the out put is supposed to look like:
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: 1
Average score of all divers: 7.74
Press any key to continue . . .
The problem i am having is the overall score comes out as 9.35?!?
Can anyone help me figure out what is wrong? Please and Thank You!
I'm having trouble understanding the reasoning behind this:
1 2
overall = (total_score - lowest - highest) / 3 * difficulty
//maybe make ur intention for the order of operations for / and * more clear ?;
The lowest and highest scores are currently not being calculated. They should be initialized at -1 probably. Then, during that first loop where u ask for each score, u should test whether the score is higher than 'highest' or lower than 'lowest'.
The total number of scores should be stored. Then, to find the overall (avg) score just divide total_score by the number of scores recorded...