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

In c++ Consider the following definition of the class studentType: public studen

ID: 3747826 • Letter: I

Question

In c++

Consider the following definition of the class studentType:

public studentType: public personType
{
public:
void print();
void calculateGPA();
void setID(long id);
void setCourses(const string c[], int noOfC);
void setGrades(const char cG[], int noOfC);

void getID();
void getCourses(string c[], int noOfC);
void getGrades(char cG[], int noOfC);
void studentType(string fName = "", string lastName = "",
long id, string c[] = NULL, char cG[] = NULL, int noOfC = 0);

private:
long studentId;
string courses[6];
char coursesGrade[6]
int noOfCourses;
)

Rewrite the definition of the class studentType so that the functions print and calculateGPA are pure virtual functions.

Explanation / Answer

If you have any doubts, please give me comment...

some of methods might be wrong check once, I changed into call by reference method... need help give me comment...

#include <string>

#include "personType.h"

using namespace std;

class studentType : public personType

{

public:

void print();

float calculateGPA();

void setID(long id);

void setCourses(const string c[], int noOfC);

void setGrades(const char cG[], int noOfC);

void getID(long &id);

void getCourses(string c[], int &noOfC);

void getGrades(char cG[], int &noOfC);

void studentType(string fName = "", string lastName = "", long id, string c[] = NULL, char cG[] = NULL, int noOfC = 0) : personType(fName, lastName);

private:

long studentId;

string courses[6];

char coursesGrade[6];

int noOfCourses;

};

void studentType::print()

{

cout << "Name: " << getFName() << " " << getLastName() << endl;

cout << "Student ID: " << studentId << endl;

cout << "No of courses: " << noOfCourses << endl;

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

{

cout << courses[i] << ": " << coursesGrade[i] << endl;

}

cout << " GPA: " << calculateGPA() << endl;

}

float studentType::calculateGPA()

{

float score = 0;

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

{

switch (coursesGrade[i])

{

case 'A':

score = score + 4;

break;

case 'B':

score = score + 3;

break;

case 'C':

score = score + 2;

break;

case 'D':

score = score + 1;

break;

case 'F':

score = score + 0;

break;

}

}

score /= noOfCourses;

return score;

}

void studentType::setID(long id)

{

student_id = id;

}

void studentType::setCourses(const string c[], int noOfC)

{

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

courses[i] = c[i];

}

void studentType::setGrades(const char cG[], int noOfC)

{

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

coursesGrade[i] = cG[i];

}

void studentType::getID(long &id)

{

id = student_id;

}

void studentType::getCourses(string c[], int &noOfC)

{

noOfC = noOfCourses;

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

c[i] = courses[i];

}

void studentType::getGrades(char cG[], int &noOfC)

{

noOfC = noOfCourses;

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

cG[i] = coursesGrade[i];

}

void studentType::studentType(string fName = "", string lastName = "", long id, string c[] = NULL, char cG[] = NULL, int noOfC = 0)

{

student_id = id;

noOfCourses = noOfC;

setCourses(c, noOfC);

setCourses(cG, noOfC);

}

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