Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Probabilistic Databases

Authors: Dan Suciu, Dan Olteanu, Christopher Re, Christoph Koch

1st Edition

3031007514, 978-3031007514

More Books

Students also viewed these Databases questions