Design a student performance system to find the students overall performance marks from subjects and sports. The student class consisting of data members such as rno, mark1 and mark2. The sports class inherits student class and consisting of data members such as sports_ mark. The statement class inherits the data members of sports class and used to find the total and average of a student.
#include <iostream>
using namespace std;
class Student{
public:
int rno, mark1, mark2;
Student(int no, int m1, int m2){
rno = no;
mark1 = m1;
mark2 = m2;
}
};
class Sports : public Student{
public:
int sports_mark;
Sports(int no, int m1, int m2, int m3) : Student(no, m1, m2){
sports_mark = m3;
}
};
class Statement : public Sports{
int total;
float average;
public:
Statement(int no, int m1, int m2, int m3) : Sports(no, m1, m2, m3){
total = mark1 + mark2 + sports_mark;
average = total / 3;
}
void display(){
cout<<"Total = "<<total<<"\nAverage = "<<average;
}
};
int main(){
int rno, mark1, mark2, sports_mark;
cout<<"Enter student rno: ";
cin>>rno;
cout<<"Enter mark1: ";
cin>>mark1;
cout<<"Enter mark2: ";
cin>>mark2;
cout<<"Enter sports_mark: ";
cin>>sports_mark;
Statement statement(rno, mark1, mark2, sports_mark);
statement.display();
return 0;
}
Comments
Leave a comment