using namespace std;
const int COUNT = 5;
const int DAYS = 7;
void inputData(string names[], int sizeOfName,
double numOfMiles[][DAYS], int rowSize)
{
ifstream infile;
infile.open("Data.txt");
int checkNames = 0, checkMiles = 0;
while (checkNames <>
{
infile >> names[checkNames];
while (checkMiles <>
{
infile >> numOfMiles[checkNames][checkMiles];
checkMiles++;
}
checkMiles = 0;
checkNames++;
}
}
void computeMiles(double status[][2], double numOfMiles
[][DAYS], int rowSize)
{
double total = 0, avg = 0;
int runCount = 0, num = 0;
cout < fixed="">< showpoint="">< setprecision(2)=""><>
while (runCount <>
{
while (num <>
{
total = total + numOfMiles[runCount][num];
num++;
}
avg = (total/DAYS);
static[runCount][0]
=
total;//error =
static[runCount][1]
=
avg;
// error =
total = 0;
avg = 0;
num = 0;
runCount++;
}
}
void displayResult(double status[][2], string names[],
int sizeOfName)
{
cout < setw(10)="">< "runner_name"=""><>
< "total="" miles"="">< setw(10)="">< "average"=""><>
int runCount = 0;
while (runCount <>
{
cout < setw(10)="">< names[runcount]=""><>
< status[runcount][0]="">< setw(10)=""><>
[1] <>
runCount++;
}
}
int main()
{
string names[COUNT];
double milesStatus[COUNT][DAYS];
double output[COUNT][2];
inputData(names, 5, milesStatus, 5);
computeMiles(output, milesStatus, 5);
displayResult(output, names, 5);
system("PAUSE");
return 0;
}