#include <iostream>
using namespace std;

class student
{
protected:
    string name;
    int roll;
    int age;
public:
    student(string n, int r, int a)
    {
        name = n;
        roll = r;
        age = a;
    }
};

class test : public student
{
protected:
    int sub[5];
public:
    test(const student &s) : student(s) {}

    void marks()
    {
        cout << "Enter marks in 5 subjects: " << endl;
        cin >> sub[0] >> sub[1] >> sub[2] >> sub[3] >> sub[4];
    }

    void display()
    {
        cout << "Name : " << name << "\nRoll number : " << roll << "\nAge: " << age << endl;
        cout << "Marks in 5 subjects : " << sub[0] << ", " << sub[1] << ", " << sub[2] << ", " << sub[3] << ", " << sub[4] << endl;
    }
};

class sports
{
protected:
    int sportmarks;
public:
    sports(int sm)
    {
        sportmarks = sm;
    }
};

class result : public test, public sports
{
    int tot;
    float perc;
public:
    result(const student &s, const sports &sp) : test(s), sports(sp) {}

    void calc()
    {
        tot = sportmarks;
        for(int i = 0; i < 5; i++)
            tot = tot + sub[i];
        perc = (tot / 600.0) * 100;
        cout << "Total: " << tot << "\nPercentage: " << perc << endl;
    }
};

int main()
{
    student ob1("Name", 781, 19);
    sports ob2(78);
    result ob(ob1, ob2);
    ob.marks();
    ob.display();
    ob.calc();
}