Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <limits>
- #include <cmath>
- #include <iomanip>
- #include <fstream>
- using namespace std;
- void gradeCalc(int studentID, int count, double midterm, double finalExam, double researchPaper, double groupProject, double participation, double studentAvg, double& overallAvg, double gradeSum, char letterGrade);
- void printGrade(int studentID, int count, double midterm, double finalExam, double researchPaper, double groupProject, double participation, double studentAvg, double& overallAvg, char letterGrade);
- int main()
- {
- int studentID;
- int count = 0;
- double midterm;
- double finalExam;
- double researchPaper;
- double groupProject;
- double participation;
- double studentAvg;
- double overallAvg;
- double gradeSum;
- char letterGrade;
- gradeCalc(studentID, count, midterm, finalExam, researchPaper, groupProject, participation, studentAvg, overallAvg, gradeSum, letterGrade);
- printGrade(studentID, count, midterm, finalExam, researchPaper, groupProject, participation, studentAvg, overallAvg, letterGrade);
- return 0;
- }
- void printGrade(int studentID, int count, double midterm, double finalExam, double researchPaper, double groupProject, double participation, double studentAvg, double& overallAvg, char letterGrade)
- {
- ifstream infile;
- ofstream outfile;
- infile.open("grades.dat");
- outfile.open("grades.txt");
- outfile << "STUDENT GRADING REPORT: ";
- outfile << fixed << showpoint << setprecision(2);
- while (!infile.eof()) {
- infile >> studentID >> midterm >> finalExam >> researchPaper >> groupProject >> participation;
- if (studentID > 1 && studentID <= 999) {
- count++;
- outfile << endl
- << "Student ID: " << studentID << ' ' << "Midterm: " << midterm << ' ' << "Final Exam: " << finalExam << ' ' << "Research Paper: " << researchPaper << ' ' << "Group Project: " << groupProject
- << "Participation: " << participation << ' ' << "Student Average: " << studentAvg << ' ' << "Letter Grade: " << letterGrade;
- }
- }
- outfile << endl
- << "Total # of Students: " << count << ' ' << "Overall Class Average: " << overallAvg;
- infile.close();
- outfile.close();
- };
- void gradeCalc(int studentID, int count, double midterm, double finalExam, double researchPaper, double groupProject, double participation, double studentAvg, double& overallAvg, double gradeSum, char letterGrade)
- {
- //midterm = .25
- //finalExam = .25
- //researchPaper = .20
- //groupProject = .20
- //participation = .10
- ifstream infile;
- ofstream outfile;
- infile.open("grades.dat");
- while (!infile.eof()) {
- infile >> studentID >> midterm >> finalExam >> researchPaper >> groupProject >> participation;
- studentAvg = ((midterm * .25) + (finalExam * .25) + (researchPaper * .20) + (groupProject * .20) + (participation * .10));
- if (studentID > 1 && studentID <= 999) {
- count++;
- gradeSum += studentAvg;
- if (studentAvg >= 90) {
- letterGrade = 'A';
- }
- else if (studentAvg >= 80 && studentAvg <= 89.99) {
- letterGrade = 'B';
- }
- else if (studentAvg >= 70 && studentAvg <= 79.99) {
- letterGrade = 'C';
- }
- else if (studentAvg < 70) {
- letterGrade = 'F';
- }
- cout << endl
- << fixed << showpoint << setprecision(2) << "Student ID: " << studentID << ' ' << "Average: " << studentAvg << ' ' << "Letter Grade: " << letterGrade;
- }
- if (count != 0) {
- overallAvg = (gradeSum / (count + 1));
- }
- }
- cout << endl
- << "Total # of Students: " << count << ' ' << "Overall Class Average: " << overallAvg;
- infile.close();
- };
Advertisement
Add Comment
Please, Sign In to add comment