Restarting C++ class after lengthy break, seems I've forgotten a lot. I can't seem to get a cout to indicate that a file record has been read.
I created a text file of just one record to keep it simple: an SS number, first and last names, and five exam scores.
Any help will be appreciated; once I have read the data from the file, I don't anticipate any problems in formatting a report from it.
Thanks,
Rich
/* Rich Mansfield 0457321 Assignment 01
This program produces a student grade report for Wexler University.
It displays 5 exam scores for each student, the student's average
grade, and the class average (average of the averages).
The data file used is "WUexamp1.txt"
The report file produced is "Wexler U Student Grade Report1.txt"
*/
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <cmath>
using namespace std;
// global variables
//named constant for number of exams
const int NUM_EXAMS = 5;
// input/output objects
ifstream input ("WUexamp1.txt");
ofstream output("Wexley U Student Grade Report1.txt");
// input data fields
string studentNo, firstName, lastName;
int examScore[NUM_EXAMS];
// accumulator
int sumOfTheAverages, sumOfTheScores;
//counter
int numberOfStudents;
//calculated field
int studentAverage, classAverage;
//function prototypes
void initialize();
void processRecord();
void finishUp();
void readRecord();
void calculateStudentAverage();
void calculateClassAverage();
void printDetailLine();
//--------------------------------------------------------------
int main()
{
initialize();
processRecord();
/*
while ( !input.eof() )
{
processRecord();
}
finishUp();
*/
return 0;
}
//--------------------------------------------------------------
void initialize()
{
input.open ("WUexamp1.txt");
}
//--------------------------------------------------------------
void processRecord()
{
readRecord();
calculateStudentAverage();
cout << "Student average is: " << studentAverage << endl;
}
//--------------------------------------------------------------
void finishUp()
{
}
//--------------------------------------------------------------
void readRecord()
{
input >> studentNo >> firstName >> lastName;
int i = 0;
while (i < NUM_EXAMS)
input >> examScore[i];
sumOfTheScores += examScore[i];
i++;
cout << "\n\nI have read the record\n\n" << endl; //doesn't get this far.
}
//--------------------------------------------------------------
void calculateStudentAverage()
{
studentAverage = floor( (double) sumOfTheScores / NUM_EXAMS + .50 );
}
//--------------------------------------------------------------
void calculateClassAverage()
{
classAverage = floor( (double) sumOfTheAverages / numberOfStudents + .50 );
}
//--------------------------------------------------------------
void printDetailLine()
{
}