Answer to Question #174310 in C++ for VARUN

Question #174310


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.



1
Expert's answer
2021-03-25T17:03:21-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS