Answer to Question #186292 in C++ for RAHUL SINGH

Question #186292

Let we have to prepare the final result of each student for a particular subject. The final

marks are sum of marks obtained by the student in T1, T2, T3, P1, P2, and attendance in theory class. Let

there are following classes:(a) Faculty: which have no data member but have a member function to assign the marks of T1, 

T2, T3, P1, P2, and percentage of attendance to each student.

(b) Administration: which have no data member but have member functions to enter the name 

and roll number of each student, and to calculate the total marks and final grade of each student. 

Grade ‘A’ for> 80% marks, ‘B’ for 70 to 80%, ‘C’ for 60 to 70%, D for 50 to 60%, F for <50%.


1
Expert's answer
2021-04-29T19:17:23-0400
#include <iostream>
using namespace std;
class T1{
    protected:
        float t1;
    public:
        T1(){}
};
class T2{
    protected:
        float t2;
    public:
        T2(){}
};
class T3{
    protected:
        float t3;
    public:
        T3(){}
};
class P1{
    protected:
        float p1;
    public:
        P1(){}
};
class P2{
    protected:
        float p2;
    public:
        P2(){}
};
class Attendance{
    protected:
        float attendance;
    public:
        Attendance(){}
};
class Student: public T1, public T2, public T3, public P1, public P2, public Attendance{
    protected:
        int rollno;
        float marks, total;
        char grade;
        string name;
    public:
        Student(): T1(), T2(), T3(), P1(), P2(), Attendance(){}
};
class Faculty: public Student{
    public:
        Faculty(float a, float b, float c, float d, float e, float f): Student(){
            t1 = a;
            t2 = b;
            t3 = c;
            p1 = d;
            p2 = e;
            attendance = f;
        }
};
class Administration: public Faculty{
    public:
        Administration(string s, int rno, float a, float b, float c, float d, float e, float f):Faculty(a, b, c, d, e, f){
            name = s;
            rollno = rno;
            marks = a + b + c + d + e + f;
            total = marks / 6;
            switch((int)total/10){
            case 10:;
            case 9:;
            case 8: this->grade = 'A'; break;
            case 7: this->grade = 'B'; break;
            case 6: this->grade = 'C'; break;
            case 5: this->grade = 'D'; break;
            default: this->grade = 'F';
            }
        }
        void display(){
            cout<<"Rollnumber: "<<rollno<<endl;
            cout<<"Name: "<<name<<endl;
            cout<<"T1: "<<t1<<endl;
            cout<<"T2: "<<t2<<endl;
            cout<<"T3: "<<t3<<endl;
            cout<<"P1: "<<p1<<endl;
            cout<<"P2: "<<p2<<endl;
            cout<<"Attendance: "<<attendance<<endl;
            cout<<"Marks: "<<marks<<endl;
            cout<<"Average: "<<total<<endl;
            cout<<"Grade: "<<grade<<endl;
        }
};
int main(){
    Administration student("Ramesh", 32, 87, 65, 72, 98, 49, 34);
    student.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