0

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] << "  ";
    }
}

Edited by mike_2000_17: Fixed formatting

0

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: ";
      }
}

Edited by mike_2000_17: Fixed formatting

0

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};

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?

0

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;

}

Edited by mike_2000_17: Fixed formatting

1

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( ).

Votes + Comments
Lots of good help on this thread.
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.