Task: Create a class Grade with private data member char letter and public data
ID: 3815323 • Letter: T
Question
Task: Create a class Grade with private data member char letter and public data member float score & protected member function void calcGrade0 & public member function void setScore(float) &float; getScore0. calcGrade0 will calculate grade according to the score. I: Write Test class which is derived from Grade class using public class access, with private data members int numQuestions, float pointsEach, int numMissed, float pointsObtEach and public member function float calcScoreo which returns score according to above data members. Write another member function void calcGrade0 which will calculate grade according to the Score. II: Write Test class which is derived from Grade class using protected class access, with private data members int num float pointsEach, int numMissed, float pointsobtEach Questions, and public member function float calcScore0 which returns score according to above data members. Write another member function void calcGrade which will calculate grade 0 according to the score III: Write Test class which is derived from Grade class using private class access, with private data members int numQuestions, float pointsEach, int numMissed, float pointsObtEach and public member function float calcScoreo which returns score according to above data members. Write another member function void calcGrade0 which will calculate grade according to the Score IV: For part I call calcGradeO function using this operator in getScoreo function to show static binding i.e. now whether getScore() is called with the instance of Grade or Test it will calculate grade for Grade class's score V: For part I now use virtual function calcGradeo and then call in getScoreo function to show dynamic binding. i.e. now when getScoreo is called with the instance of Grade it will calculate grade for Grade class's score. And when called with Test it will calculate grade according to Test class Score.Explanation / Answer
This is what can be done for the first 4 points:
#include <iostream>
using namespace std;
class Grade
{
private:
char letter;
protected:
void calcGrade();
public:
float score;
void setScore(float);
float getScore()
{
this->calcGrade();
}
};
class Test1 : public Grade
{
private:
int numQuestions;
float pointsEach;
int numMissed;
float pointsObtEach;
public:
float calcScore();
void calcGrade();
};
class Test2 : protected Grade
{
private:
int numQuestions;
float pointsEach;
int numMissed;
float pointsObtEach;
public:
void calcGrade();
};
class Test3 : private Grade
{
private:
int numQuestions;
float pointsEach;
int numMissed;
float pointsObtEach;
public:
float calcScore();
void calcGrade();
};
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.