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

C++ CODE GradStudents are Students but they have the additional data member of r

ID: 3774790 • Letter: C

Question

C++ CODE

GradStudents are Students but they have the additional data member of researchArea.

Your program will loop asking for one of three options (add, print, or quit).

Add user option: You will create (using new) a Student object or a GradStudent object and add its pointer to the vector classMembers.

Print user option: You will print the entire class last, using the appropriate ToStr member function. You should NOT test whether a particular pointer in the class list points to a Student or a GradStudent. The correct ToStr function will be called automatically if you have properly defined functions for ToStr.

CODE!!

#include <iostream>
#include <string>
#include <vector>
using namespace std;

class Student {
public:
   Student(string initialName = "No Name") {
       name = initialName;
   }

   // Enter definition for a virtual ToStr member function here.

protected:
   string name;
};

class GradStudent : public Student {
public:
   // Enter definition for a paramteriezed contructor function here that sets both data members.

   // Enter definition for a virtual ToStr member function here.

private:
   string researchArea;
};

int main() {
   string usrOption;
   string inpName;
   string inpResearch;
   vector<Student*> classMembers;

   do {
       cout << "Option: ";
       cin >> usrOption;
       cout << endl;
       if (usrOption == "print") {
           // Enter code here to print each member pointed to from classMembers using their respective ToStr member functions.
           }
       }

       else if (usrOption == "add") {
           cout << "Name: ";
           cin >> inpName;
           cout << endl;
           cout << "If grad student enter a one word research area, else enter "NO": ";
           cin >> inpResearch;
           cout << endl;
           if (inpResearch == "NO") {
               // Enter code here to create new objects (using new) for either a Student or a GradStudent
               // and add the pointer to the classMember vector.

           }
       }
   } while (usrOption != "quit");
   return 0;
}

Option add Name: Mary If grad student enter a one word research area, else enter "NO" MachineLearning Option add Name Bob If grad student enter a one word research area else enter NO NO Option print Mary is a graduate student researching the area of MachineLearning. Bob is an undergraduate student. Option quit

Explanation / Answer

#include #include #include using namespace std; class Student { protected: int social; string name; public: Student (); // Default constructor Student(int ssn, string StudentName); void setSSN(int); int getSSN(); void setName(string); string getName(); virtual double calcGPA(); }; Student ::Student() { } Student::Student(int ssn, string StudentName) { social = ssn; name = StudentName; return; } void Student::setSSN(int SSN) { social = SSN; return; } int Student::getSSN() { return (social); } void Student::setName(string name2) { name = name2; return; } string Student::getName() { return name; } double Student::calcGPA() { cout points; ug->setQualityPts(points); cout setSSN(StudentSSN); cout > Status; gs->SetStatus(Status); cout