Question: #include #include using namespace std; class student{ public: string name1; string name2; char grade; //getter and setter functions void setName1(string n1); string getName1(); void setName2(string

#include #include using namespace std; class student{ public: string name1; string name2; char grade; //getter and setter functions void setName1(string n1); string getName1(); void setName2(string n2); string getName2(); void setGrade(char a); char getGrade(); //Print function to print the details void print(); }; //function definitons void student::setName1(string n1) { this->name1=n1; } string student::getName1(){ return name1; } void student::setName2(string n2){ this->name2=n2; } string student::getName2() { return name2; } void student:: setGrade(char a){ this->grade=a; } char student::getGrade(){ return grade; } void student::print(){ cout<<"Name: "<>n; for(int i=0;i<=n;i++){ cout<<"Enter your first name"<>score; calcGrade(score); grade=calcGrade(score); obj[i].setGrade(grade); } for(int i=0;i<=n;i++){ obj[i].print(); } } //function to calculate the grade based on score. char calcGrade(float s) { char grade; if(s>=90||s==100)//if grade is greater than or equal to 90 and equal to 100, student gets an A { grade='A'; }else if(s<89||s>=80){//if grade is less than 89 and greater than or equal to 80, student gets a B grade='B'; }else if(s<79||s>=70){//if grade is less than 79 and greater than or equal to 70, student gets a C grade='C'; }else{ grade='D'; } return grade; }

Can someone explain this code Please

Thank You!!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!