ou are reqaired to write the declaration and implemeatation code in separate sub
ID: 3872835 • Letter: O
Question
ou are reqaired to write the declaration and implemeatation code in separate submission is to reflect this. Examine the folloing class specifications, additional infomation and answer the questions that follow ting cod: nt marks char grade ting ccaTyps, Vspors.arta.awrvice (acivicw) char grado CCAIing-".sairu--.dia, ;.'). void deployCCM Module m sting achievement NDtinotien. Fist Clasa Second Class. In Poge old osloulsteAahlvementi Modulul.tring .-.tng r1i-. Constructor with dcfaudt vahues foc module code, name and marks. grades cuupuled as per the nuctizati uguen Table 2.1 Uses cor to display all data members Accessor. Rehm the data member, . char getGrodelx Constctut with default values. all data members Accessor. Retum the data member. with array of 6 Module and aray of4 CCA objects. Assigns "In progress as defanuly vahue for achievement Compates grade-point-average (a) 5 modules Grade points each modale is assigned as given beloa Grade A-45 grade B-4 grade C- .5, grade D-3, grade F-0 If there are 3 or ore 'A gardes in CCAs, 0.5 ponits is added to the average grade point of 6 moles Compates and assipnes the class to the data member achievement as per the infoanation 1 in Table 2.2 to display all data members Invoke respective display method in co each clas: mak, 50 and (a) Analyse and develop C code to impleme ALL the methods found in the above 5 marks) 4 marks) (12 anks) b) Write a test driver to test ALI. the methods in the osule, CCA and SnudemtProgress class specification Modale Class () CCA Class ) StudenPiogiess Class classes. The test drivr should at least includr the following: Instantiates aays of Module and CCA class objects. Initlises them with arbary alues ) Instaniales an instzace of StudiemProgress and calls ceuseAchievement0 and arpiyProgress) to comute and display the stucdent's modnles, CCAs and achievement class a screen output in your subinission. 4 marks)Explanation / Answer
Module Class:
class Module{
private:
string code;
string name;
int marks;
char grade;
public:
Module(string str1="",string str2="",int n=0);
char getGrade(){
char tempG;
if(marks>=80)
tempG='A';
else if(marks>=70&&marks<80)
tempG='B';
else if(marks>=60&&marks<70)
tempG='C';
else if(marks>=50&&marks<60)
tempG='D';
else tempG='F';
return tempG;
}
void displayModule(){
cout<<"Current Code: "<<code<<" ";
cout<<"Current Grade: "<<grade<<" ";
cout<<"Current marks: "<<marks<<" ";
}
};
Module::Module(string str1,string str2,int n){
code=str1;
name=str2;
marks=n;
}
CCA Class:
class CCA{
private:
string ccaType;
string ccaDesg;
char grade;
public:
CCA(string str1="",string str2="",char c='0');
char getGrade(){
return grade;
}
void displayCCA(){
cout<<"Current CCAType: "<<ccaType<<" ";
cout<<"Current CCADesig: "<<ccaDesg<<" ";
cout<<"Current grade: "<<grade<<" ";
}
};
CCA::CCA(string str1,string str2,char g){
ccaType=str1;
ccaDesg=str2;
grade=g;
}
studentProgress Class:
class StudentProgrssion {
private:
Module m[];
CCA c[];
string achievement;
public:
studentProgress(Module m[],CCA c[]);
void calculateAchievement(){
int counter=1;
double extraPoint=0;
//code to detect the grade 'A' in CCA
for(int i=0;i<4;i++){
if(c[i].getGrade()=='A')
counter++;
}
/if student got 'A' more than 3 times extra point awarded.
if(counter>=3)extraPoint=0.5;
double gSum=0;
for(int i=0;i<6;i++){
switch(m[i].getGrade()){
case 'A':
gSum+=4.5;
break;
case 'B':
gSum+=4.0;
break;
case 'C':
gSum+=3.5;
break;
case 'D':
gSum+=3.0;
break;
default:
gSum+=0;
break;
}
}
gSum+=extraPoint;
if(gSum>=4.5)
achievement="Distinction";
else if(gSum>=4&&gSum<4.5)
achievement="First Class";
else if(gSum>=3.5&&gSum<4)
achievement="Second Class";
else achievement="In Progress";
}
void displayProgress(){
cout<<"Current Achievement: "<<achievement;
}
};
StudentProgrssion ::StudentProgrssion (Module mod[6],CCA cca[4]){
m = new Module[6];
for (int i(0); i < 6; i++) {
m[i] = mod[i];
}
c = new CCA[6];
for (int i(0); i < 4; i++) {
c[i] = cca[i];
}
}
Test driver:
Module mod1=new Module("code1","m1",67);
Module mod2=new Module("code2","m2",57);
Module mod3=new Module("code3","m3",77);
Module mod4=new Module("code4","m4",87);
Module mod5=new Module("code5","m5",87);
Module mod6=new Module("code6","m6",97);
CCA c1=new CCA("service",''txt1",'B');
CCA c2=new CCA("service",''txt2",'A');
CCA c3=new CCA("service",''txt3",'A');
CCA c4=new CCA("service",''txt4",'B');
Module m[6]={mod1.mod2,mod3,mod4,mod5,mod6};
CCA c[4]={c1,c2,c3,c4};
StudentProgrssion sp1=new StudentProgrssion(m,n);
sp1.displayProgress();
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.