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
|
#include<iostream>
#include<iomanip>
#include <fstream>
#include<string>
using namespace std;
const int MAX_HW_SCORES = 10;
void ReadStudentInfo(string& fullname, double hwScores[MAX_HW_SCORES], int& i);
void CalcHomeworkScores(double& maxNum, double& minNum, double& avgNum, char& letterGrade, double grades[MAX_HW_SCORES], int gradesEntered);
void GradeReport(ostream& out, const string fullname, double hwScores[MAX_HW_SCORES], int gradesEntered, const double maxNum, const double minNum, const double avgNum, const char letterGrade);
void WriteLine(int size, char ch, ostream& out);
string FirstName();
string LastName();
double HomeworkScores(double hwScores[MAX_HW_SCORES], int i);
bool ValidGrade(double score);
bool MoreScores();
bool YesOrNo(char answer);
bool MoreStudents();
double MaxScore(double hwScores[MAX_HW_SCORES], int amountOfGrades);
double MinScore(double hwScores[MAX_HW_SCORES], int amountOfGrades);
double AverageScore(double hwScores[MAX_HW_SCORES], int amountOfGrades);
char LetterGrade(double average);
int main()
{
ofstream outfile;
string studentname;
char studentLetterGrade;
double studentGrades[MAX_HW_SCORES], maxHwScore, minHwScore, averageHwScore;
int numberOfGradesEntered;
do{
ReadStudentInfo(studentname, studentGrades, numberOfGradesEntered);
CalcHomeworkScores(maxHwScore, minHwScore, averageHwScore, studentLetterGrade, studentGrades, numberOfGradesEntered);
GradeReport(cout, studentname, studentGrades, numberOfGradesEntered, maxHwScore, minHwScore, averageHwScore, studentLetterGrade);
outfile.open(studentname + "'s" +" Homework Grades.txt");
GradeReport(outfile, studentname, studentGrades, numberOfGradesEntered, maxHwScore, minHwScore, averageHwScore, studentLetterGrade);
} while (MoreStudents());
return 0;
}
|