I am trying to take the following code so that my bottom function first pulls out the first three scores of a text file and averages them, then pulls the last three scores out and averages them. I am using a known good text file that has 7 entries with first and last name folowed by the 6 scores followed by a return and the next entry.
Here is the current code, everything works up to the calcAveragefn
//**************************************
//IT 210 Business Applications with C++
// Programmer: Randell Wright
// Date:Oct 23, 2007
// Program: Template Program
//**************************************
//Preprocessor Directives
#include<iostream>
#include<conio.h>
#include<iomanip>
#include<fstream>
#include<string>
using namespace std;
ifstream fin; //global variable
//Global constants/global variables/function prototypes
//declarations
string names[40][2];
int scores[40][6];
int total;
//function prototypes
void headerfn(); //void function with no parameters
void inputfn(string names[40][2], int scores[40][6], int &counter);
int calcAverage(float average[40][6], string names[40][2], int scores[40][6], int &counter);
//char assignGrade(int average);
//Definition of main function
void main()
{
headerfn(); //call to headerfn
//start of block in main
float average[40][6];
fin.open("input.txt");
if(!fin)
{
cout<<"input error\npress any key"<<endl;
getch();
return;
}//end of error check
int counter;
inputfn(names,scores, counter);
calcAverage(average, names, scores, counter);
//end of block in main
cout<<"\n\nPress any key to continue"<<endl;
getch();
}//end of main
//*****************************************************************
void headerfn()
{
cout<<"********************************************"<<endl;
cout<<"IT210 Business Applications with C++"<<endl;
cout<<"Programer: Randell Wright "<<endl;
cout<<"Date : October 23, 2007"<<endl;
cout<<"Program : Template program"<<endl;
cout<<"********************************************"<<endl;
}
//*****************************************************************
void inputfn(string names[40][2], int scores[40][6], int &counter)
{
int total[40];
counter=0;
while(fin&&counter<40)
{
fin>>names[counter][0]>>names[counter][1];
for(int col=0;col<6;col++)fin>>scores[counter][col];
counter++;
if(fin.peek()=='\n')fin.ignore();
}//end of while
for (int row =0; row<counter; row++)
{
total [row]=0;
for (int col=0; col<6; col++)
total[row]= total [row] + scores [row][col]; }//end of outer loop
for (int row=0; row<counter; row++) {cout<<left<<setw(20)<<names[row][0]+' '+names[row][1];
for (int col=0; col<6;col++) {cout<<setw(5)<<scores[row][col];} cout<<setw(5)<<total[row];
cout<<endl;
}//end of outer for
}//end of inputfn
//*****************************************************************
int calcAverage(float average[40][6], string names[40][2], int scores[40][6], int &counter)
{
counter=0;
//for (int row=0; row<counter; row++)
// {
for (int col=2; col<8; col++)
{
return average[40][6];
cout<<average;
}
int Ptotal[40][3];
Ptotal =0;
for(int col =2; col<5;col++){Ptotal += scores[col]
}cout<<Ptotal;
}//end of outer for
//*****************************************************************
Thanks for the help