Answer in C++ [12 pts] Define the class Student. The Student class has a name(st
ID: 3722547 • Letter: A
Question
Answer in C++
[12 pts] Define the class Student. The Student class has a name(string), totalCreditslint) and pricePerCreditidouble) 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 compute Tution() that evaluate the tuition due (credits $ per credit) returns a double a. [6 pts] 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. b. [6 pts] 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. [6 pts] Show the sample tuns of the program by displaying the result for the objects of different classes (Student, MasterStudent, PhdStudent). In one example demonstrate polymorphism. c.Explanation / Answer
Class Student
{
private:
char name[50];
int totalCredit;
double pricePerCredit;
public:
\default constructor
Student()
\Constructor with Parameter
Student(char *n,int tc, double ppc )
{
strcpy(this->name,n);
this->totalCredit=tc;
this->pricePerCredit=ppc;
}
int computeTution()
{
return(totalCredit * pricePerCredit);
}
};
class MasterStudent: public Student
{
private:
double graduateFee;
MasterStudent()
\Constructor with Parameter
MasterStudent(char *n,int tc, double ppc, double GF )
{
strcpy(this->name,n);
this->totalCredit=tc;
this->pricePerCredit=ppc;
this-> graduateFee=GF;
}
int computeTution()
{
return(totalCredit * pricePerCredit + graduateFee);
}
};
class PhdStudent: public MasterStudent
{
private:
double researchFee;
PhdStudent()
\Constructor with Parameter
PhdStudent(char *n,int tc, double ppc, double GF, double RF)
{
strcpy(this->name,n);
this->totalCredit=tc;
this->pricePerCredit=ppc;
this-> graduateFee=GF;
this-> researchFee=RF;
}
int computeTution()
{
return(totalCredit * pricePerCredit + graduateFee + researchFee);
}
};
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.