So I've ran this properly and everything seems to be set up correctly.
However, I am still stumped on asking the user if they want to run the program again after either using case 1 or case 2, but it needs to have a cout statement clarifying they have quit this program if they have decided to quit like in case 3.
i was thinking about a while loop, I tried it and i don't think i did it correctly
int main(){
// variables used for program
int choice;
int NumOfGymnasts = 0;
int getValidScore();
string name;
//code to welcome the user to the generator
cout << "Welcome to the Gymnastics Copetition Score Results!" << endl;
do
{
// start asking how many judges for the competition
cout << "Please pick from the following...\n" << endl;
cout << "1. 3 Judges \n" << endl;
cout << "2. 5 Judges \n" << endl;
cout << "3. Quit" << endl;
cin >> choice;
switch (choice)
{
// choice for 3 judges
case 1:
//narrowing down how many competitors and start calculation for scores
cout << "How many gymnasts are in the competition. Between 1-20 competitors\n" << endl;
cin >> NumOfGymnasts;
//entering a limit for how many gymnast in competition
if (NumOfGymnasts >= 1 && NumOfGymnasts <= 20)
{
//once clarified, varifying name and scores for gymnast in competition
for (int j =0; j < NumOfGymnasts; j++)
{
//asking user for gymnast name
cout << "Enter the gymnast name here...\n" << endl;
getline(cin, name);
cin >> name;
//identifiers for scores for three judges
double FIRST_SCORE, SECOND_SCORE, THIRD_SCORE;
double AVERAGE_SCORE;
// output and calculations to provide average scoe for contestant
AVERAGE_SCORE = (FIRST_SCORE + SECOND_SCORE + THIRD_SCORE) / 3;
cout << fixed << setprecision(2);
cout << "Average score for contestant " << name << "is" << AVERAGE_SCORE << endl;
}
}
break;
case 2:{
// narrowing down how many competitors and start calculation for scores with 5 judges
cout << "How many gymnasts are in the competition. Pick between 1-50\n" << endl;
cin >> NumOfGymnasts;
// entering the limit for how many gymnast in competiton for 5 judges
if(NumOfGymnasts >= 1 && NumOfGymnasts <=50)
{
// once clarified, varifying name and scores for gymnasts in competition
for (int i = 0; i < NumOfGymnasts; i++)
{
//asking user for gymnast name
cout << "Enter the gymnast name here ...\n" << endl;
getline(cin, name);
cin >> name;
//identifiers for scores for five judges
double FIRST_SCORE, SECOND_SCORE, THIRD_SCORE, FOURTH_SCORE, FIFTH_SCORE;
double AVERAGE_SCORE;
while(true)
{
// start asking how many judges for the competition
cout << "Please pick from the following...\n" << endl;
cout << "1. 3 Judges \n" << endl;
cout << "2. 5 Judges \n" << endl;
cout << "3. Quit" << endl;
cin >> choice;
switch(choice)
{
case 1: //whatever
case 2: //whatever
case 3: std::cout << "Exiting\n"; return 0;
}
}
The code will automatically run the program again after selecting and finishing either 1 or 2, and will only terminate once the user hits 3. You don't have to ask the user if they want to run the program again. It will do it automatically.
Also, your code is very long and messy. Please use code tag and please split your switch case into functions. You should have a seperate function for threeJudges() and fiveJudges().