You are viewing a single comment's thread. Return to all comments →
CPP solution
class Student : public Person{ private: vector<int> testScores; public: Student(string firstName, string lastName,int identification,vector<int> scores) :Person(firstName,lastName,identification){ this->testScores=scores; } char calculate(){ int sum=0; for(int i=0;i<testScores.size();i++){ sum+=testScores[i]; } int avg=sum/testScores.size(); if(90<=avg && avg<=100){ return 'O'; }else if(80<=avg && avg<90){ return 'E'; }else if(70<=avg && avg<80){ return 'A'; }else if(55<=avg && avg<70){ return 'P'; }else if(40<=avg && avg<55){ return 'D'; }else { return 'T'; } } };
Seems like cookies are disabled on this browser, please enable them to open this website
Inheritance
You are viewing a single comment's thread. Return to all comments →
CPP solution