Question & Answer: Please answer in C++ not any other language!…..

Please answer in C++ not any other language!
The problem asks you to implement a CourseGrades class that contains the five member functions given in the problem. The CourseGrades class should also contain an array of size 4 of GradedActivity pointers called grades (note that it does not say an array of GradedActivitys, but rather its an array of pointers to GradedActivitys). Each of those four pointers will be initialized with the four set member functions described in the problem. (For example, setLab will initialize grades [0]. setPassFailExam) will initialize grades [1].) Your program should:
Question & Answer: Please answer in C++ not any other language!..... 1
Question & Answer: Please answer in C++ not any other language!..... 2

The problem asks you to implement a CourseGrades class that contains the five member functions given in the problem. The CourseGrades class should also contain an array of size 4 of GradedActivity pointers called grades (note that it does not say “an array of GradedActivitys”, but rather it’s an “array of pointers to GradedActivitys”). Each of those four pointers will be initialized with the four “set” member functions described in the problem. (For example, setLab will initialize grades [0]. setPassFailExam) will initialize grades [1].) Your program should:

Expert Answer

 

GradeActivity.h
———————–
#include <iostream>
#include <string>
class GradeActivity
{
public:
GradeActivity();
~GradeActivity();
GradeActivity(float s){
score = s;
}
void printScore(){
std::cout << “score ” << score << “n” ;
}
private:
float score;
};
———————- End———————–
CourseGrade.h
————————
#include <iostream>
#include <string>
#include “GradeActivity.h”
using namespace std;
class CourseGrade
{
public:
CourseGrade(){
store = new GradeActivity*[4];
}

~CourseGrade(){}

void setLab(GradeActivity* ga){
store[0] = ga;
}
void setPassFailExam(GradeActivity* ga){
store[1] = ga;
}
void setEssay(GradeActivity* ga){
store[2] = ga;
}
void setFinalExam(GradeActivity* ga){
store[3] = ga;
}

void print(){
for(int n=0;n<4;n++){
GradeActivity* ff = store[n];
ff->printScore();
}
}
public:
GradeActivity **store ;
};
——- End——————————–
main.cpp
—————-
#include <iostream>
#include <string>
#include “CourseGrade.h”
int main(){

CourseGrade* cg = new CourseGrade();

GradeActivity* labScore = new GradeActivity(85.7);
cg->setLab(labScore);

GradeActivity* passFailScore = new GradeActivity(70);
cg->setPassFailExam(passFailScore);

GradeActivity* essayScore = new GradeActivity(70);
cg->setEssay(essayScore);

GradeActivity* finalExamScore = new GradeActivity(50);
cg->setFinalExam(finalExamScore);

cg->print();

return 0;
}

———- End————————–

Output
——————

sh-4.2$ g++ -o main *.cpp
sh-4.2$ main
score 85.7
score 70
score 70
score 50

description:

1. Two header files are added to define the classes ( CourseGrade, GradeActivity)

2. Need to execute main method of main.cpp class to see the output.

Please let me know if you need more assistence on above code.

Still stressed from student homework?
Get quality assistance from academic writers!