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

C++ I need all steps please. Define the class Student . The Student class has a

ID: 3866605 • Letter: C

Question

C++ I need all steps please.

Define the class Student. The Student class has a name(string), totalCredits(int) and pricePerCredit(double) as private data members. Include default constructor, which is blank and a constructor with parameter to initialize the all private data members. The Student class must include the method computeTuition() that evaluate the tuition due (credits * $ per credit) returns a double

Derive the Class MasterStudent from the Student, the MasterStudent class has one additional private data member called graduateFee(double). Supply constructors and override the method computeTuition(). The MaterStudent tuition is computed the same as the regular Student except that the graduatefee is added.

Derive the class PhdStudent from the MasterStudent. The PhdStudent has one additional private data member called researchFee (double). Supply constructors and override the method computeTuition(). The PhdStudent tuition is computed the same as the MasterStudent except that the researchFee is added.

Demonstrate polymorphism using these classes

Explanation / Answer

#include<iostream>
#include<string>

using namespace std;

class Student
{
private:
     string name;
     int totalCredits;
     double pricePerCredit;
public:
      Student(){
      }
      Student(string nm, int tc, double pr){
         name = nm;
         totalCredits = tc;
         pricePerCredit = pr;
      }
      virtual double computeTuition(){
          return pricePerCredit * totalCredits;
      }
};

class MasterStudent: public Student
{
private:
     double graduateFee;
public:
      MasterStudent(): Student(){
      }
      MasterStudent(string nm, int tc, double pr, double grfee) : Student(nm,tc,pr){
         graduateFee = grfee;
      }
      double computeTuition(){
          return (Student::computeTuition() + graduateFee);
      }
};

class PhdStudent: public Student
{
private:
     double resarchFee;
public:
      PhdStudent(): Student(){
      }
      PhdStudent(string nm, int tc, double pr, double rsfee) : Student(nm,tc,pr){
         resarchFee = rsfee;
      }
      double computeTuition(){
          return (Student::computeTuition() + resarchFee);
      }

};


int main(){

    Student *ptr;
    Student st("John",34, 100.00);
    MasterStudent mst("Harry",34, 70.00,150.00);
    PhdStudent pst("Marry",34, 80.00,200.00);

    ptr = &st;
    cout << "Tuition Fee: " << ptr->computeTuition() << endl;
    ptr = &mst;
    cout << "Tuition Fee: " << ptr->computeTuition() << endl;
    ptr = &pst;
    cout << "Tuition Fee: " << ptr->computeTuition() << endl;
    return 0;
}