I'm late turning in the assignment. Oh well, I'm not going to submit it until its right

My output comes out as:

Visitor scores are 18 19 22 21 22 23 25 17

I'm want it to be

Visitors scores are   18 19 22 21
Home scores are     22 23 25 17

I did cout<<"Visitor scores are"<<endl; but I can't find how to do it the way I want to do it.

int finalScore (int teamscores[][COLS],string teams[])
{

      int sum = 0;  

      cout<<"Visitor scores are ";
      for (int i=0; i<ROWS; i++)   
      { 
      sum = 0 ;

    for (int j=0;j<COLS; j++)     
    {
        sum = sum+teamscores[i][j];
        cout << teamscores[i][j] << "  ";
    }
}

use the string values in teams[], and output a newline between the two team's worth of data.

Alrite, this seemed to work for me even though I don't think it is how I was suppose to do it..LOL Alrite, I somehow lost the sum of the scores for each team...I had it first..Arg!

I thought: sum = sum+teamscores[i][j]; was suppose to cover for it. o_O

int finalScore (int teamscores[][COLS],string teams[])
{

      int sum = 0;  

      cout<<"Visitor: ";
      for (int i=0; i<ROWS; i++)   
      { 
      sum = 0 ;
    for (int j=0;j<COLS; j++)     
    {
        sum = sum+teamscores[i][j];
        cout << teamscores[i][j] << "  ";
     }
       cout<<" "<<endl;
       cout<<"Home: ";
      }
}

Nevermind, "Home: " got printed out twice...Darn it!

Alrite...how do I use the values in the string that I had? Is this how?

cout<<teams[ROWS] = {Visitor};
cout<<" "<<endl;
cout<<teams[ROWS] = {Home};

cout << teams[i] << ":  ";
     for( j = 0; ......

How come I didn't get the sum anymore for both teams? I need it for the final score. I think I had it at first with the same code, but it disappeared.

How come "sum = sum+teamscores[j];" didn't calculate the sums of the scores anymore for the final score?

Alrite, I figured the above part out.... I'm in the AverageQtrScore() now.

How do I seperate the sum of both teams so I can divide by 4 (numofQtrs)?

int averageQtrScore (int teamscores[][COLS])
{

    const int numofQtrs = 4;
     int sum = 0;
     double homeavg;
     double visitoravg;

       for (int i=0; i<ROWS; i++)   
       { 
       sum = 0 ;
       for (int j=0;j<COLS; j++)     
       {
       sum = sum+teamscores[i][j];

       homeavg = sum/numofQtrs;
       visitoravg = sum/numofQtrs;

 }

      }
      cout<<" "<<endl;
      cout<<"Vistors Average Quarter Score: "<<visitoravg<<endl;
      cout<<"Home Average Quarter Score:  "<<homeavg<<endl;

}

You could run the j loop only, and hardcode the row index into accumulator for each team.

You could use the same looping as for finalScore( ), again passing the team names to the function. Index into them with the i counter.

This function is really just a variation on the finalScore( ).

commented: Lots of good help on this thread. +7
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.