I need to complete derived class and main class:
derived class should have data member: major(string), grades: an array of integrs (size 5).
it should have methods to:
1-set and get the major.
2-insert a grade in the grades array.
3-compute the gpa of the 5 courses.
THEN:
MAIN METHOD THAT :
1-Creat a diploma student.
2-et the name of the student to a value that program gets from the user.
3-sets itt gender and age after getting them from the user.
4-sets the major a value that the user gets interactive.
5-sets 5 grades to value that user inters interactively.
6-displays the name of students his gender,his age and major.
7-computes the GPA of this student.
creates a second diploma student whoes name sami and age 21,his major math ,he has the same grade s as the fist student.Use message passing to assign grades to the second student.
8-Display the grades of the first student and second student in a form of table of two rows.
========================================
#include <iostream>
using namespace std;
class student
{
protected:
int id;
string name;
char gender;
int age;
public :
student (){name=" ";gender=' ';age=0;id=0;}
void setid(int s){id=s;}
void setName(string n){name=n;}
void setGender(char m){gender=m;}
void setAge(int g){age=g;}
int getid(){return id;}
string getName(){return name;}
char getGender(){return gender;}
int getAge(){return age;}
};
class dpstudent : public student{
protected:
string major;
int grade[5];
public:
dpstudent(){ for(int i=0;i<5;i++)grade[i]=0;major=' ';}
void setmajor(string j){major=j;}
void setGrade(int ag[]){ for(int i=0;i<5;i++) grade[i]=ag[i];}
int getGrade(int i){return grade[i];}
string getmajor(){return major;}
int computegpa(){int m=0;int gpa=0;
for(int i=0;i<5;i++) m=m+grade[i];
gpa=m/5;
return gpa;}
};
int main(){
int grade[5];
string name;
char m;
int age;
string major;
dpstudent f;
cout<<"enter the name of frist student"<<endl;
cin>>name;
f.setName("name");
cout<<"enter the gender"<<endl;
cin>>m;
f.setGender('m');
cout<<"enter the age"<<endl;
cin>>age;
f.setAge(age);
cout<<"enter the major"<<endl;
cin>>major;
f.setmajor("major");
for(int i=0;i<5;i++){
cout<<"enter the grade: ";
cin>>grade[i];
}
for( i=0;i<5;i++)
cout<<grade[i]<<endl;
cout<<"the gpa of the 5 courses is"<<f.computegpa()<<endl;
return 0;
}