Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Task You will design a set of classes for storing student information, along wit

ID: 3853688 • Letter: T

Question

Task

You will design a set of classes for storing student information, along with a main program that will read student information from a file, store the data, compute final grades, and then print a summary report to an output file.

Details

1. Design a set of classes that store student grade information. There should be one base class to store common data, and three derived classes that divide the set of students into three categories: English students, History students, and Math students.

All data stored in these classes should be private or protected. Any access to class data from outside should be done through public member functions. The base class should allocate storage for the following data (and only this data):

o student's first name (you may assume 20 characters or less)

o student's last name (you may assume 20 characters or less)

o Which course the student is in (English, History, or Math)

Separate specifications from your implementation. Submit your program as YourName_LastName_B5.cpp, your header file (YourName-B5.h), and YourName_main-B5.cpp files.

At the beginning of your program in comment section write your group members and their responsibilities. Also, you must include which function(s) or method(s) is/are implemented by whom in the group.

2. Each class should have a function that will compute and return the student's final average, based on the stored grades. All grades are based on a 100 point scale. Here are the grades that need storing for each subject, along with the breakdown for computing each final grade:

English -- Attendance = 10%, Project = 30%, Midterm = 30%, Final = 30%

History -- Term Paper = 25%, Midterm = 35%, Final = 40%

Math -- There are 5 quizzes, to be averaged into one Quiz Average (which can be a decimal number). Final grade computed as follows: * Quiz Average = 15%, Test 1 = 25%, Test 2 = 25%, Final = 35%

3.Write a main program (in a separate file) that does the following (in this order):

a) Ask the user for input file name and display output on screen. (See the sample run below).

b) Read the student data from the input file and store it using an array of appropriate type. You will need to allocate this list dynamically (if you are not using vectors), since the size is stored in the input file. Each student's data should be stored in a separate object. (Any dynamically allocated space should be cleaned up appropriately with delete when you are finished with it).

c) Print a summary report to the screen, as specified below. You'll need to use the function that computes the final average when you do this, since the final averages will be included in this summary report.

4. File formats

Input File -- The first line of the input file will contain the number of students listed in the file. This will tell you how big a list you need. After the first line, every set of two lines constitutes a student entry. The first line of a student entry is the name, in the format lastName, firstName. Note that a name could include spaces -- the comma will delineate last name from first name. The second line will contain the subject ("English", "History", or "Math"), followed by a list of grades (all integers), all separated by spaces. The order of the grades for each class type is as follows:

English -- Attendance, Project, Midterm, Final

History -- Term Paper, Midterm, Final

Math -- Quiz 1, Quiz 2, Quiz 3, Quiz 4, Quiz 5, Test 1, Test 2, Final

5. General Requirements

o No global variables, other than constants!

o All member data of your classes must be private or protected

o Use the const qualifier on member functions wherever it is appropriate.

o You may use any of the standard libraries that have been discussed in class (iostream, iomanip, fstream, as well as C libraries, like cstring, cctype, etc). You may also use the string class library if you wish.

Sample run

Screen input and output: (keyboard input is underlined)

Please enter the name of the input file. Filename: test.txt Processing!

Here is result:

Student Grade Summary ---------------------

ENGLISH CLASS

Student Final Final Letter

Name Test Avg Grade

----------------------------------------------------------------

Marvin Dipwart 88 80.30 B

James T. Kirk 88 80.80 B

HISTORY CLASS Student Final Final Letter

Name Test Avg Grade

----------------------------------------------------------------

Joe Schmuckatelli 90 84.25 B

Monica Lewinsky 78 71.40 C

MATH CLASS

Student Final Final Letter

Name Test Avg Grade

----------------------------------------------------------------

Bugs Bunny 93 94.83 A

Jimmy Crack Corn 68 65.33 D

Sample input file:

6

Bunny, Bugs Math 90 86 80 95 100 99 96 93

Schmuckatelli, Joe History 88 75 90

Dipwart, Marvin English 95 76 72 88

Crack Corn, Jimmy Math 44 58 23 76 50 59 77 68

Kirk, James T. English 40 100 68 88

Lewinsky, Monica History 60 72 78

Explanation / Answer

driver.cpp


#include <iostream>
#include <iomanip>
#include <cstring>
#include "student.h"

using namespace std;

int main()
{
///////////////////////INPUT////////////////////////////////////////////

//Variables
int numStudents;   // size
char fn[20];       // Stores students first name
char ln[20];       // Stores students last name
char c[8];           // Stores course
// math class variables
double q1, q2, q3,q4, q5, t1, t2;
int mf;  
// history class variables
double tp, hm;
int hf;  
// egnlish class variables
double at, pr, em;
int ef;
//-----------------------------------------------------------------------
cin >> numStudents;                               // copy number of students
Student ** list = new Student * [numStudents];   // an array of Student pointers
cin.ignore(80, ' ');                           // next line

   for (int i=0; i<numStudents; i++)
   {
   cin.getline(ln, 20, ',');       // copy last name
   cin.ignore(1);                   // skip space
   cin.get(fn, 80, ' ');           // copy first name       
   cin.ignore(80, ' ');           // next line
   cin.getline(c, 8, ' ');           // copy course name
   if (c[0] == 'M') // Math Class
       {
       cin >> q1;       // copy quiz1
       cin >> q2;       // copy quiz2
       cin >> q3;       // copy quiz3
       cin >> q4;       // copy quiz4
       cin >> q5;       // copy quiz5
       cin >> t1;       // copy test1
       cin >> t2;       // copy test2
       cin >> mf;      
       cin.ignore(80, ' ');       // next line
       // sends to English_Student Class (Dynamically)
       list[i] = new Math_Students(fn, ln, c, numStudents,q1,q2,q3,q4,q5,t1,t2,mf);
       }
   else if (c[0] == 'H') // History Class
       {
       cin >> tp;               // copy term paper
       cin >> hm;               // copy midterm
       cin >> hf;               // copy final  
       cin.ignore(80, ' ');   // next line
       // sends to History_Student Class (Dynamically)
       list[i] = new History_Students(fn, ln, c, numStudents, tp, hm, hf);  
       }
   else // English Student
       {
       cin >> at;               // copy attendance
       cin.ignore(1);           // skip space
       cin >> pr;               // copy project
       cin.ignore(1);           // skip space
       cin >> em;               // copy midterm
       cin.ignore(1);           // skip space
       cin >> ef;               // copy final
       cin.ignore(80, ' ');   // next line
       // sends to Math_Student Class (Dynamically)
       list[i] = new English_Students(fn, ln, c, numStudents, at, pr, em, ef);  
       }
   }
///////////////////////OUTPUT//////////////////////////////////////
   list[0]->DisplayTitle();           // Display Main Title
   list[0]->SubDisplayTitle(1);       // Display English SubTitle
   // Output all English Students
   for (int i=0; i<numStudents; i++)          
   {
   if (list[i]->Get_course() == 'E')
       list[i]->Summary();
   }
  
   list[0]->SubDisplayTitle(2);       // Display History SubTitle
    // Output all History Students
   for (int i=0; i<numStudents; i++)          
   {
   if (list[i]->Get_course() == 'H')
       list[i]->Summary();
   }
      
   list[0]->SubDisplayTitle(3);       // Display Math SubTitle
   // Output all Math Students
   for (int i=0; i<numStudents; i++)          
   {
   if (list[i]->Get_course() == 'M')
       list[i]->Summary();
   }
/////////////////////////////////////////////
   // deallocate data
   for (int i=0; i<numStudents; i++)          
       delete list[i];  
   delete [] list;

   return 0;
}


student.cpp

#include <iostream>      
#include <cstring>       //for strcmp
#include "student.h"
#include <iomanip>       // for formatting
using namespace std;

Student::Student(char* fn, char* ln, char* c, int s)
// Constructor
{
   strcpy(firstName,fn);       // copy firstname
   strcpy(lastName,ln);       // copy lastname
   strcpy(course,c);           // copy course
   numStudents =s;               // copy number of students
   finalAvg =0;               // initailize final avg to 0;
}

void English_Students::Summary()
// Output on Visual and G++ is fine, pygraders may be different
{
   // Output English Student Information
   cout << firstName << " ";  
   cout << lastName;
   if (strlen(firstName)+strlen(lastName) >= 14)
       cout << " ";
   else
       cout << " ";
   cout << Get_finalExamGrade();
   cout << " ";
    cout << fixed << setprecision(2) << FinalAvg();
   cout << "    ";
   if (finalAvg < 60)
       cout << "F ";
   else if ((finalAvg >= 60) && (finalAvg < 70))
       cout << "D ";
   else if ((finalAvg >= 70) && (finalAvg < 80))
       cout << "C ";
   else if ((finalAvg >= 80) && (finalAvg < 90))
       cout << "B ";
   else
       cout << "A ";
}

void History_Students::Summary()
// Output on Visual and G++ is fine, pygraders may be different
{
   // Output History Student Information  
   cout << firstName << " ";
   cout << lastName;
   if (strlen(firstName)+strlen(lastName) >= 15)
       cout << " ";
   else
       cout << " ";
   cout << Get_finalExamGrade();
   cout << " ";
    cout << fixed << setprecision(2) << FinalAvg();
   cout << "    ";
   if (finalAvg < 60)
       cout << "F ";
   else if ((finalAvg >= 60) && (finalAvg < 70))
       cout << "D ";
   else if ((finalAvg >= 70) && (finalAvg < 80))
       cout << "C ";
   else if ((finalAvg >= 80) && (finalAvg < 90))
       cout << "B ";
   else
       cout << "A ";
}

void Math_Students::Summary()
// Output on Visual and G++ is fine, pygraders may be different
{
   // Output Math Student Information
   cout << firstName << " ";
   cout << lastName;
   if (strlen(firstName)+strlen(lastName) >= 14)
       cout << " ";
   else
       cout << " ";
   cout << Get_finalExamGrade();
   cout << " ";
   cout << fixed << setprecision(2) << FinalAvg();
   cout << "    ";
   if (finalAvg < 60)
       cout << "F ";
   else if ((finalAvg >= 60) && (finalAvg < 70))
       cout << "D ";
   else if ((finalAvg >= 70) && (finalAvg < 80))
       cout << "C ";
   else if ((finalAvg >= 80) && (finalAvg < 90))
       cout << "B ";
   else
       cout << "A ";
}
English_Students::English_Students(char* fn, char* ln, char* c, int s,
                                   double a, double p, double m, int f) : Student(fn, ln, c, s)
// Contructor for English_Students
{
attendanceGrade = a; // Store info
projectGrade = p;
midtermGrade = m;
finalExamGrade =f;
}

History_Students::History_Students(char* fn, char* ln, char* c, int s,
                           double tp, double m, int f) : Student(fn, ln, c, s)
// Contructor for History_Students
{
termPaperGrade = tp; // store info
midtermGrade = m;
finalExamGrade = f;
}

Math_Students::Math_Students(char* fn, char* ln, char* c, int s,
                           double q1, double q2, double q3,
                           double q4, double q5, double t1,
                           double t2, int f) : Student(fn, ln, c, s)
// Contructor for Math_Students
{
quiz1Grade = q1;   // store info
quiz2Grade = q2;
quiz3Grade = q3;
quiz4Grade = q4;
quiz5Grade = q5;
test1Grade = t1;
test2Grade = t2;
finalExamGrade = f;
}

double English_Students::FinalAvg()

{
   finalAvg = (attendanceGrade*.1) + (projectGrade*.3)
               + (midtermGrade*.3) + ((double)finalExamGrade*.3);

   return finalAvg;
}

double History_Students::FinalAvg()

{
   finalAvg = termPaperGrade*.25 + midtermGrade*.35
               + (double)finalExamGrade*.4;

   return finalAvg;
}

double Math_Students::FinalAvg()

{
   finalAvg = ((quiz1Grade + quiz2Grade + quiz3Grade +
               quiz4Grade + quiz5Grade)/5)*(.15)
               + test1Grade*(.25) + test2Grade*(.25) + (double)finalExamGrade*(.35);

   return finalAvg;
}

void Student::DisplayTitle()
// Prints out main Title.
{
   cout << "Student Grade Summary "
   << "---------------------";
}

void Student::SubDisplayTitle(int c)
// Prints out SubTitle
// Passed in course to output correct subTitle
// Output on Visual and G++ is fine, not pygraders though
{
if (c == 1)
{cout << " ENGLISH CLASS ";
cout << "Student Final   Final   Letter ";
cout << "Name Exam    Avg     Grade "
<< "---------------------------------------------------------------- ";}
else if (c == 2)
{cout << " HISTORY CLASS ";
cout << "Student Final   Final   Letter ";
cout << "Name Exam    Avg     Grade "
<<"---------------------------------------------------------------- ";}
else
{cout << " MATH CLASS ";
cout << "Student Final   Final   Letter ";
cout << "Name Exam    Avg     Grade "
<< "---------------------------------------------------------------- ";}
}

//Accessor Deffinitions
int English_Students::Get_finalExamGrade() const
{return finalExamGrade;}          
int History_Students::Get_finalExamGrade() const
{return finalExamGrade;}          
int Math_Students::Get_finalExamGrade() const
{return finalExamGrade;}          
char Student::Get_course() const
{return course[0];}                  

student.h


class Student   // Base Class
{
public:
           Student(char* fn, char* ln, char* c, int s);   // Constructor
           virtual double FinalAvg()=0;                   // Base Final Average Function
           virtual void Summary()=0;               // Base Summary function
           char Get_course() const;               // Returns Course[0] value
           void DisplayTitle();                   // Prints Title for output
           void SubDisplayTitle(int c);           // Prints SubTitle for output
          
protected:
           char firstName[20];       // Stores students first name for all students
           char lastName[20];       // Stores students last name for all students
           char course[8];           // Stores course for all students
           int numStudents;       // Stores number of students
           double finalAvg;       // Stores final average for all students
          
};

/////////////////ENGLISH////////////////////////////////
class English_Students : public Student
// derived from Student
{
public:
       English_Students(char* fn, char* ln, char* c, int s,   // firstname,lastname,course,size,
                       double a, double p, double m, int f); // attendance,project,midterm,final
           double FinalAvg();               // Returns Final Average
           void Summary();                   // Prints Summary
           int Get_finalExamGrade() const;   // returns final exam grade
          
private:
           double attendanceGrade;       // Stores attendance grade for enlish students
           double projectGrade;       // Stores project grade   for enlish students
            double midtermGrade;       // Stores midterm grade for enlish students
           int finalExamGrade;           // Stores final grade for enlish students
};
///////////////////HISTORY/////////////////////////////
class History_Students : public Student
// derived from Student
{
public:
           History_Students(char* fn, char* ln, char* c, int s,
                           double tp, double m, int f);
           double FinalAvg();                   // Returns Final Average
           void Summary();                       // Prints Summary
           int Get_finalExamGrade() const;       // Returns final grade
private:
           // Grades that were inputed from file
           double termPaperGrade, midtermGrade;
           int finalExamGrade;
};
/////////////////MATH////////////////////////////////////////
class Math_Students : public Student
// derived from Student
{
public:
           Math_Students(char* fn, char* ln, char* c, int s,
                           double q1, double q2, double q3,
                           double q4, double q5, double t1,
                           double t2, int f);
           double FinalAvg();                   // Returns Final Average
           void Summary();                       // Prints Summary
           int Get_finalExamGrade() const;       // Returns Final grade
private:
           // Grades that were inputed from file
           double quiz1Grade, quiz2Grade, quiz3Grade,
               quiz4Grade, quiz5Grade, test1Grade,
               test2Grade;
           int finalExamGrade;
};

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote