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, double midterm, double finalExam, double researchPaper, double groupProject, double participation, double studentAvg);
- void printGrade(int studentID, double midterm, double finalExam, double researchPaper, double groupProject, double participation, double studentAvg);
- int main()
- {
- int studentID;
- double midterm;
- double finalExam;
- double researchPaper;
- double groupProject;
- double participation;
- double studentAvg;
- gradeCalc(studentID, midterm, finalExam, researchPaper, groupProject, participation, studentAvg);
- printGrade(studentID, midterm, finalExam, researchPaper, groupProject, participation, studentAvg);
- return 0;
- }
- void printGrade(int studentID, double midterm, double finalExam, double researchPaper, double groupProject, double participation, double studentAvg)
- {
- 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) {
- outfile << endl
- << "Student ID: " << studentID << ' ' << "Midterm: " << midterm << ' ' << "Final Exam: " << finalExam << ' ' << "Research Paper: " << researchPaper << ' ' << "Group Project: " << groupProject
- << "Participation: " << participation << ' ' << "Student Average: " << studentAvg;
- }
- }
- infile.close();
- outfile.close();
- };
- void gradeCalc(int studentID, double midterm, double finalExam, double researchPaper, double groupProject, double participation, double studentAvg)
- {
- //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) {
- cout << endl
- << fixed << showpoint << setprecision(2) << "Student ID: " << studentID << ' ' << "Average: " << studentAvg;
- }
- }
- infile.close();
- };
Advertisement
Add Comment
Please, Sign In to add comment