Here is the entire code;

#include <iostream>
#include <sstream>
#include <cstdlib>

using namespace std;

const int MIN_SCORE = 0;
const int MAX_SCORE = 300;
const int numofgamesinseries = 3;
const int numofplayersonteam = 4;

void printintromessage ();
void getUserInput(char& Y);
int getInt(const string &, int minValid, int maxValid);

typedef struct 
{
  int score[numofgamesinseries];
} 

  player_t;

int main(int argc, char *argv[]) 
{
    player_t players[numofplayersonteam];
    char Y;
    int k = 1;
    int l = 1;
    double seriesScore, avg;
    stringstream prompt;
    int i;

    printintromessage();
    getUserInput(Y);
    
    do 
       {
        
        if (Y == 'Y' || Y == 'y') 
         {
            cout <<"Enter scores for team " << k++ << endl;
            for (int j = 0; j < numofplayersonteam; j++) 
            {
                seriesScore = 0;
                for (i = 0; i < numofgamesinseries; i++) 
                {
                    prompt.str("");
                    prompt << "Enter player " << j+1 << "'s score " << i+1 << ": ";
                    players[j].score[i] = getInt(prompt.str(), MIN_SCORE, MAX_SCORE);
                    seriesScore += players[j].score[i];
                }
                cout << "Player " << j+1 << ":" << endl;
                for (i = 0; i < numofgamesinseries; i++) 
                {
                    cout << ". Game " << i+1 << " : " << players[j].score[i] << endl;
                }
                cout << ". Series : " << seriesScore << endl;
                avg = seriesScore / numofgamesinseries;
                cout << ". AVG : " << avg << endl << endl;
            }
        
            cout << "Team " << l++ << " Totals" <<  endl;
            cout << "Game 1 : " <<   << endl;
            cout << "Game 2 : " <<  << endl;
            cout << "Game 3 : " <<  << endl;
            cout << "Series : " <<  << endl;
            cout << "AVG : " <<  << endl;
             
               
        }
        else 
        
        {
            cout << "All finished ? Thank you !" << endl;
        }
        getUserInput(Y);
    } 
    while ((Y == 'Y' || Y == 'y'));

    return EXIT_SUCCESS;
}

int getInt(const string &prompt, int minValid, int maxValid) 
{
    stringstream ss;
    string line;
    bool inputOk = false;
    int n;

    cout << prompt;
    do {
        getline(cin,line);
        ss.clear(); ss.str(line);
        if ((!(ss >> n)) || (ss.good()) ||
                (n < minValid) || (n > maxValid)) {
            cout << endl << "That is not a valid score! score must be from "
                      << minValid << " to " << maxValid << " "
                      << endl << "Re-enter please: ";
        } else {
            inputOk = true;
        }
    } while (inputOk == false);
    return n;
}

void printintromessage () 
{
    cout << "This program processes bowling scores." << endl;
    cout << "The user is asked to enter "
              << numofgamesinseries << " bowling scores" << endl;
    cout << "for each person on the team. There are "
              << numofplayersonteam << " people" << endl;
    cout << "per team. After all the scores are entered" << endl;
    cout << "for a player, the program will list the individual" << endl;
    cout << "game scores,the player's total score (series), and" << endl;
    cout << "the player's average.After each team's input is complete," << endl;
    cout << "the program will list the team's total scores by game," << endl;
    cout << "the team's total score (series)and the team's average." << endl;
    cout << "The user will then be asked if he/she wants to" << endl;
    cout << "enter more data. If not, the program will list the" << endl;
    cout << "team with the highest total score (series) and that " << endl;
    cout << "total. If the user wants to enter more data," << endl;
    cout << "the above process is repeated." << endl;
    cout << " " << endl;
}

void getUserInput (char& Y) 
{
    string in;

    cout << "Do you want to enter (more) data?" << endl;
    cout << "Enter Y to continue, anything else to quit: ";
    getline(cin,in);
    Y = in[0];
    cout << " " << endl;
}
do 
       {
        
        if (Y == 'Y' || Y == 'y') 
         {
            cout <<"Enter scores for team " << k++ << endl;
            for (int j = 0; j < numofplayersonteam; j++) 
            {
                seriesScore = 0;
                for (i = 0; i < numofgamesinseries; i++) 
                {
                    prompt.str("");
                    prompt << "Enter player " << j+1 << "'s score " << i+1 << ": ";
                    players[j].score[i] = getInt(prompt.str(), MIN_SCORE, MAX_SCORE);
                    seriesScore += players[j].score[i];
                }
                cout << "Player " << j+1 << ":" << endl;
                for (i = 0; i < numofgamesinseries; i++) 
                {
                    cout << ". Game " << i+1 << " : " << players[j].score[i] << endl;
                }
                cout << ". Series : " << seriesScore << endl;
                avg = seriesScore / numofgamesinseries;
                cout << ". AVG : " << avg << endl << endl;
            }
        
            cout << "Team " << l++ << " Totals" <<  endl;
            cout << "Game 1 : " <<   << endl;
            cout << "Game 2 : " <<  << endl;
            cout << "Game 3 : " <<  << endl;
            cout << "Series : " <<  << endl;
            cout << "AVG : " <<  << endl;

My problem is specifically in the 2nd posted code; I'm not sure how to properly print the contents of the array, what I want it to do is take all 4 players game 1 and add them and print then game 2, game 3 etc.. how would I do this???

Create another series of loops similar to your input loops. Just convert them to output and perform the necessary arithmetic operations inside them.

This article has been dead for over six months. Start a new discussion instead.