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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
#ifndef MFP1_H
#define MFP1_H
// Include files
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
//Function prototypes
int fnOpenFiles(ifstream&, ofstream&);
// a. Open input file, open output file
void fnInitialize(char&);
// a. Initialize variables.
void fnInitialize(double&);
// a. Initialize variables.
void fnInitialize(int&);
// a. Initialize variables.
void fnInitialize(string&);
// a. Initialize variables.
void fnSumGrades(char&, double, double&, double&, int&, int&);
// a. Sum the GPAs and accumulate count for each gender
double fnAverageGrade(int, double);
// a. Average male GPAs, average female GPAs.
void fnPrintResults(string, double, ofstream&);
// a. Output results to OutFile--floating point number
void fnPrintResults(string, int, ofstream&);
// a. Output results to OutFile--integer number
#endif
// MFP1.cpp
#include "MFP1.h"
int fnOpenFiles(ifstream& inFile, ofstream& outFile) // Open input file: Ch7_Ex6Data.txt, open output file: Ch7_Ex6out.txt
{
// Open input file
inFile.open("Ch7_Ex6Data.txt");
// Input file success check
if(!inFile)
{
cout << "Cannot open file--program terminated!";
system("pause");
return 1; // Return that error code
}
// Open output file
outFile.open("Ch7_Ex6out.txt");
// Set ouput format
outFile << fixed << showpoint << setprecision(2);
return 0;
}
|