Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For higest and lowest scores, it always gives me a 0 for the lowest score. I'm trying to get the lowest score input by the

For higest and lowest scores, it always gives me a 0 for the lowest score. I'm trying to get the lowest score input by the user to show as 'lowest'

// CIS 5 - ONLINE // CH 1 - 5 MIDTERM 1 // 10/25/2021 //

#include #include #include #include #include #include

using namespace std;

int main()

{ char run = true; int choice; int gymnasts = 0; string name; double score; const string belowAvg = "Sorry your final score is below average. You will not advance in the competition.", avgScoreString = "Nice! You have placed in the competition, and are able to advance to the next round!", aboveAvg = "Congratulations!! Your final score is above average and youre going to the finals!"; double average = 0; double highest = 0; double lowest = 0;

cout << setprecision(2) << setw(2) << "\t\t2022 Olympic Games" << endl << "\t\tScore Board" << endl;

do { //Do display menu while run is true cout << "What scoring system will you be using?" << endl << "The 3 judge syetem or The 5 judge system " << endl << "\t\t3. Three judges" << endl << "\t\t5. Five judges" << endl << "\t\t8. Quit" << endl << "Enter your choice" << endl; cin >> choice;

switch (choice) { case 3: cout << "You chose our three judge scoring system " << endl; cout << "How many gymnasts are in the competition? " << endl; cin >> gymnasts;

if (gymnasts >= 1 && gymnasts <= 20) { for (int i = 0; i < gymnasts; i++) { average = 0; cout << "Enter the gymnast name" << endl; cin.ignore(); getline(cin, name);

for (int j = 0; j < 3; j++) { while (true) { cout << "Please enter all of your scores." << endl << " scores must be between 1 and 10." << endl; cin >> score;

if ((score >= 0 && score <= 10)) { break; } else { cout << "ERROR! Scores must be between 1 and 10!" << endl; } } average += score; } average = average / 3; for (int i = 0; i < gymnasts; i++)

cout << "Final Score for " << name << " is " << average << endl; if (average > 0 && average <= 5) { cout << belowAvg << endl; } if (average > 5 && average <= 8) { cout << avgScoreString << endl; } if (average >= 8) { cout << aboveAvg << endl; break; } } } char runAgain; cout << "Do you wish for the program to run again?," << endl << "Y for Yes" << "N for No"; cin >> runAgain; if (runAgain) { run = true; } else { run = false; } break;

case 5: cout << "You chose our five judge scoring system " << endl; cout << "How many gymnasts are on your team?" << endl; cin >> gymnasts;

if (gymnasts >= 1 && gymnasts <= 50) { for (int i = 0; i < gymnasts; i++) { cout << "Enter the gymnast name" << endl; cin.ignore(); getline(cin, name);

for (int j = 0; j < 5; j++) { while (true) { cout << "Enter the gymnast score between 0 and 10" << endl; cin >> score;

if ((score >= 0 && score <= 10)) { break; } else { cout << "ERROR. Score must be between 1 and 10!" << endl; }

} if (score > highest) {

highest = score;

}

if (score < lowest) {

lowest = score;

} average += score; // avg = avg + score

} average = average - highest - lowest; average = average / 3; cout << "Highest and Lowest scores for contestant " << name << " are " << highest << " and " << lowest << endl; cout << "Final score for " << name << " is " << average << endl; if (average > 0 && average <= 5) {/* cout << belowAvg; } if (average > 5 && average <= 8) { cout << avgScoreString; } if (average >= 8) { cout << aboveAvg << endl; break; }*/ } }

cout << "Do you wish for the program to run again?," << endl << "Y for Yes" << "N for No"; cin >> runAgain; if (runAgain == 'Y' || runAgain == 'y') { run = true; } else { run = false; } break;

case 8: cout << "Quit."; return 0; run = false; break;

default: cout << "ERROR! Please input " << endl; run = true; } } } while (run);

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions