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

PURPOSE: • learn to work with multiple classes Description: This assignment is s

ID: 3785484 • Letter: P

Question

PURPOSE: • learn to work with multiple classes

Description: This assignment is similar to the first project. In this assignment, please write a program that provides a way for you to search and display information of all students in the class. Student records including c# and scores of multiple categories are saved in the file point.dat.

Your program should: • First, read all student information from the text file and store them in an array of Student objects. • Calculate total score and final letter grade. The total score is the sum of CLA, OLA, Quiz, Homework, Exam and Bonus. There will be five letter grades, A(>=90), B(>=80), C(>=70), D(>=60), and F(<60). The letter grade is determined based on the total score. For example, if the term grade is 79, then the letter grade is C, and if the term grade is 89, then the letter grade is B.

• Prompt user to input a valid c#, and the program display all information of the student with the given c#, including the total score and final letter grade. • Then display information of all students, including total score and final letter grade.

You can proceed as follows:

• Design and implement the class Student, which represents ID, score information of a student. You will store instances of this class in the Roster class. • Design and implement the class Roster, which represents class roster and provides approaches to manage the roster.

here are both .h files

#ifndef __CSCI3110_ROSTER__
#define __CSCI3110_ROSTER__

#include
#include
#include "Student.h"

class Roster
{
   public:

       // constructor, the parameter is the course name
       // Create an empty roster, i.e. m_studentNum = 0 for
       // a specific course
       Roster(std::string courseName);

       // This function reads student information from a file
       // The parameter is a file name
       // post-condition:
       //       m_students contains student information read from the file
       //       m_studentNum is the number of students read from the file  
       void readStudentRecord( std::string );

       //*****************************************
       //Add your functions here if necessary
       //*****************************************

   private:
       static const int   MAX_NUM = 25;   // The maximum # of students of a class
                                           // Class constant. All objects share the same copy
       std::string           m_courseName;   // THe name of the course
       int                   m_studentNum;   // Actual Student #
       Student               m_students[MAX_NUM]; // The array of student objects
};
#endif

#ifndef __CSCI3110_STUDENT__
#define __CSCI3110_STUDENT__

#include
#include


class Student
{
   public:
       // The types of score. You can access the type or enumerators outside
       // of the Student class scope by the following expressions:
       //   Student::ScoreType Student::CLA Student::BONUS
       enum ScoreType {CLA, OLA, QUIZ, HOMEWORK, EXAM, BONUS};

       // To access the class constant outside of the Student class scope:
       //   Student::CATEGORY_NUM
       static const int CATEGORY_NUM = BONUS - CLA + 1;

       // default constructor. This is necessary since we define an array
       // of students in the class Roster
       Student( void );

       //Accessor & mutator of m_id
       std::string getID( void ) const;
       void setID( std::string ) ;

  
       //Accessor and mutator of m_score
       //ScoreType indicates which score you want to access
       void changeScore( const ScoreType, const int );
       int getScore( const ScoreType ) const;

       //********************************************************************
       //Add your functions here if necessary
//like getters and setters for m_total and m_letterGrade
       //********************************************************************

   private:
       std::string       m_id;       // Student ID
       int               m_score[CATEGORY_NUM];
                       // m_score[CLA] is CLA score      
                       // m_score[OLA] is OLA score      
                       // m_score[QUIZ] is QUIZ score      
                       // m_score[HOMEWORK] is HOMEWORK score      
                       // m_score[EXAM] is EXAM score      
                       // m_score[BONUS] is BONUS score
int m_total; //total score, which is the sum of all scores
char m_letterGrade;
};
#endif

the text file

ID CLA OLA Quiz Homework Exam Bonus Total FinalGrade   
c088801 10 15 4 15 56 5
c088802 9 12 2 11 46 2
c088803 8 10 3 12 50 1
c088804 5 5 3 10 53 3
c088805 3 11 1 10 45 0
c088806 8 14 2 11 40 -1
c088807 4 12 2 12 48 -2
c088808 10 10 3 11 36 0
c088809 8 8 3 11 39 0
c088810 6 9 4 9 47 3
c088811 8 7 3 13 41 3
c088812 6 8 1 7 45 1
c088816 7 7 2 6 51 2
c088817 8 9 2 12 38 2

Explanation / Answer

#include <iostream>

#include <fstream>

using namespace std;

//declare a structure Student to hold all information of a student, such as C# and all scores.

typedef struct Student

{

string ID;

int CLA;

int OLA;

int Quiz;

int Homework;

int Exam;

int Bonus;

int Total;

char FinalGrade;

}Student;

//a function to read from the text file

int readFile(ifstream &fin, Student Roster[])

{

string temp;

getline(fin, temp);

int count = 0;

while(!fin.eof())

{

fin>>Roster[count].ID>>Roster[count].CLA>>Roster[count].OLA>>Roster[count].Quiz;

fin>>Roster[count].Homework>>Roster[count].Exam>>Roster[count].Bonus;

count++;

}

return count;

}

//a function to print one student

void printStudent(Student Roster[], string ID, int count)

{

for(int i = 0; i < count; i++)

if(Roster[i].ID == ID)

{

cout<<"ID: "<<Roster[i].ID<<endl;

cout<<"CLA: "<<Roster[i].CLA<<endl;

cout<<"OLA: "<<Roster[i].OLA<<endl;

cout<<"Quiz: "<<Roster[i].Quiz<<endl;

cout<<"Homework: "<<Roster[i].Homework<<endl;

cout<<"Exam: "<<Roster[i].Exam<<endl;

cout<<"Bonus: "<<Roster[i].Bonus<<endl;

cout<<"Total: "<<Roster[i].Total<<endl;

cout<<"FinalGrade: "<<Roster[i].FinalGrade<<endl;

}

}

//a function to print information of all students

void printAllStudents(Student Roster[], int count)

{

for(int i = 0; i < count; i++)

printStudent(Roster, Roster[i].ID, count);

}

int main()

{

//declare a local variable Roster in main function as an array of Student structure.

Student Roster[30];

//First, read all student information from the text file and store them in an array.

ifstream fin;

fin.open("point.dat");

int count = readFile(fin, Roster);

//Prompt user to input a valid c#

cout<<"Enter the C# to search the student details: ";

string ID;

cin>>ID;

//display all information of the student with the given c#.

printStudent(Roster, ID, count);

//Then display information of all students.

printAllStudents(Roster, count);

}