riggnaros

Grading Calc

Oct 25th, 2017
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.65 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <limits>
  4. #include <cmath>
  5. #include <iomanip>
  6. #include <fstream>
  7.  
  8. using namespace std;
  9.  
  10. void gradeCalc(int studentID, double midterm, double finalExam, double researchPaper, double groupProject, double participation, double studentAvg);
  11. void printGrade(int studentID, double midterm, double finalExam, double researchPaper, double groupProject, double participation, double studentAvg);
  12.  
  13. int main()
  14. {
  15.     int studentID;
  16.     double midterm;
  17.     double finalExam;
  18.     double researchPaper;
  19.     double groupProject;
  20.     double participation;
  21.     double studentAvg;
  22.  
  23.     gradeCalc(studentID, midterm, finalExam, researchPaper, groupProject, participation, studentAvg);
  24.     printGrade(studentID, midterm, finalExam, researchPaper, groupProject, participation, studentAvg);
  25.  
  26.     return 0;
  27. }
  28.  
  29. void printGrade(int studentID, double midterm, double finalExam, double researchPaper, double groupProject, double participation, double studentAvg)
  30. {
  31.  
  32.     ifstream infile;
  33.     ofstream outfile;
  34.  
  35.     infile.open("grades.dat");
  36.     outfile.open("grades.txt");
  37.     outfile << "STUDENT GRADING REPORT: ";
  38.     outfile << fixed << showpoint << setprecision(2);
  39.  
  40.     while (!infile.eof()) {
  41.  
  42.         infile >> studentID >> midterm >> finalExam >> researchPaper >> groupProject >> participation;
  43.  
  44.         if (studentID > 1 && studentID <= 999) {
  45.  
  46.             outfile << endl
  47.                     << "Student ID: " << studentID << ' ' << "Midterm: " << midterm << ' ' << "Final Exam: " << finalExam << ' ' << "Research Paper: " << researchPaper << ' ' << "Group Project: " << groupProject
  48.                     << "Participation: " << participation << ' ' << "Student Average: " << studentAvg;
  49.         }
  50.     }
  51.  
  52.     infile.close();
  53.     outfile.close();
  54. };
  55.  
  56. void gradeCalc(int studentID, double midterm, double finalExam, double researchPaper, double groupProject, double participation, double studentAvg)
  57. {
  58.  
  59.     //midterm = .25
  60.     //finalExam = .25
  61.     //researchPaper = .20
  62.     //groupProject = .20
  63.     //participation = .10
  64.  
  65.     ifstream infile;
  66.     ofstream outfile;
  67.  
  68.     infile.open("grades.dat");
  69.  
  70.     while (!infile.eof()) {
  71.  
  72.         infile >> studentID >> midterm >> finalExam >> researchPaper >> groupProject >> participation;
  73.         studentAvg = ((midterm * .25) + (finalExam * .25) + (researchPaper * .20) + (groupProject * .20) + (participation * .10));
  74.  
  75.         if (studentID > 1 && studentID <= 999) {
  76.  
  77.             cout << endl
  78.                  << fixed << showpoint << setprecision(2) << "Student ID: " << studentID << ' ' << "Average:  " << studentAvg;
  79.         }
  80.     }
  81.  
  82.     infile.close();
  83. };
Advertisement
Add Comment
Please, Sign In to add comment