1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
const int SIZE = 40;
const int COLUMN = 5;
void getData(ifstream& inf, string n[], double tstData[][COLUMN], int count);
void calculateAverage(double tstData[][COLUMN], int count);
void calculateGrade(double tstData[][COLUMN], char gr[], int count);
void print(string n[], double tstData[][COLUMN], char gr[], int count);
int main()
{
string names[SIZE];
double testData[SIZE][COLUMN];
char grade[SIZE];
ifstream inFile;
inFile.open("employed_15-24yrsOld.txt");
if (!inFile)
{
cout << "Cannot open the input file: ch8_Ex13Data.txt." << endl;
cout << "Program terminates!" << endl;
return 1;
}
cout << fixed << showpoint << setprecision(2);
getData(inFile, names, testData, SIZE);
calculateAverage(testData, SIZE);
calculateGrade(testData, grade, SIZE);
print(names, testData, grade, SIZE);
inFile.close();
return 0;
}
|