I have to write a program that will read a file that lists the scores for two teams.
1st 2nd 3rd 4th
Visitors 17 18 21 20 Final Score: 76
Home 21 22 24 16 Final Score: 83
Input file will look like: 17 18 21 20 21 22 24 16
The program must have a function for each of the following:
1) readFile - read from the file and populate the 2d array
2) finalScore - prints 'Visitors or Home", each qtr. score and final score
3) averageQtrScore - prints both teams' average quarter score
4) highScore - print the highest score and which quarter
Sample Output:
FinalScore
Visitors 17 18 21 20 76
Home 21 22 24 16 83
Visitors Average Quarter Score: 20.871 (made up answer)
Home Average Quarter Score: 21.234 (made up answer)
Home team had highest scoring quarter. They had 24 points in quarter #3.
I have to get the program to look like that, but not exactly like that. So far, I'm having trouble getting the program to run at all. I appreciate the help. I'm trying to figure out one error saying "declaration of '<name>' as array of references.
Here is my code:
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
const int rows = 2;
const int cols = 5;
void readFile(ifstream& inData, ofstream& outData);
void finalScore(int& totalscores[][cols]);
void averageQtrScore (int& team_avg_scores[][cols]);
void highscore (int& highestscore[][cols], int totalscores);
int main()
{
int Homescores[4] = {'22','23','25','17'};
int Visitorscores[4] = {'18','19','22','21'};
string teams[2] = {"Visitors","Home"};
int avg;
int high_score;
ifstream inData;
ofstream outData;
outData<<fixed<<showpoint;
outData.precision(2);
readFile(inData,outData);
finalScore(Homescores,Visitorscores);
averageQtrScore(avg);
highscore(high_score,Homescores,Visitorscores);
inData.close();
outData.close();
system ("PAUSE");
return 0;
void readFile (ifstream& inData, ofstream& outData);
{
inData.open("UnknownLab.txt")
outData.open("UnknownLab_output.txt");
}
void finalScore(int& totalscores);
{
while (inData>>scores)
{
int sum = 0;
sum+=scores;
cout<<teams<<" "<<scores<<endl;
}
void averageQtrScore (int& team_avg_scores);
{
int j=1;
int i=1;
for (i=0; i<rows; i++)
{
for (int j=0; j<cols; j++)
sum+=grades[i][j];
avg = sum/cols;
cout<<"Vistors average score is "<<(i+1<<" is "<<avg<<endl;
sum = 0;
}
void highscore (int& highestscore, int totalscores);
{
while (inData>>scores)
{
int scores;
highestscore = high_score[0];
for (int i = 0; i<cols; i++)
if (scores < highest)
highest = high_score[i];
cout<<
}