Computer Science, asked by julie37, 4 months ago

We want to calculate the total marks of each student of a class in Physics,Chemistry and
Mathematics and the average marks of the class. The number of students in the class are entered
by the user. Create a class named Marks with data members for roll number, name and marks.
Create three other classes inheriting the Marks class, namely Physics, Chemistry and Mathematics,
which are used to define marks in individual subject of each student. Roll number of each student
will be generated automatically.

Answers

Answered by lavanshsingh26
0

Answer:

bro do it on excel Microsoft office

Explanation:

here no answer getting is tha

Answered by adityamishra3648
0

Answer:

Here is the code in c++

Explanation:

#include <iostream>

#include <string>

using namespace std;

static int totalmo =0;

static int totalmm =0;

class marks

{

protected:

   int roll_number;

   string name;

public:

   void setinfo(string namex,  int roll)

   {

       name = namex;

       // score = scorex;

       roll_number = roll;

   }

};

class physics : virtual public marks

{

protected:

   int phy;

public:

   void setphysics(int phyx)

   {

       phy = phyx;

       totalmo +=phy;

       totalmm +=1;

   }

};

class chemistry : virtual public marks

{

protected:

   int chem;

public:

   void setchemistry(int chemx)

   {

       chem = chemx;

       totalmo +=chem;

       totalmm +=1;

   }

};

class maths : virtual public marks

{

protected:

   int math;

public:

   void setmaths(int mathx)

   {

       math = mathx;

       totalmo +=math;

       totalmm +=1;

   }

};

class student : public physics, public chemistry, public maths

{

   public:

   void getanswer()

   {

       cout<<endl;

       cout << "The name of the student is: " << name << endl;

       cout << "The roll number of the student is: " << roll_number << endl;

       cout << "marks in physics is: " << phy << endl;

       cout << "marks in chemistry is: " << chem << endl;

       cout << "marks in Matmatics is: " << math << endl;

       cout << "Total marks of the student is: " <<phy + chem + math

       <<" out of 300"<< endl;

   }

};

int main()

{

   int n;

   cout << "The number of students you have"<<endl;

   cin>>n;

   cin.ignore();

   student s[n];

   for (int i = 0; i <  n; i++)

   {

       string nam;

       // int scor;

       cout<<"Enter the name of the student \n";

       getline(cin,nam);

       // cout<<"Enter the score of the student \n";

       // cin>>scor;

       s[i].setinfo(nam,i+1);

       int p;

       cout<<"Enter the score of the student in physics \n";

       cin>>p;

       s[i].setphysics(p);

       int c;

       cout<<"Enter the score of the student in chemistry \n";

       cin>>c;

       s[i].setchemistry(c);

       int M;

       cout<<"Enter the score of the student in Mathmatics \n";

       cin>>M;

       cin.ignore();

       s[i].setmaths(M);

   }

   for ( int i = 0; i < n; i++)

   {

      s[i].getanswer();

   }

   cout<<endl;

   cout << "The average marks accross all the subject of students is "

   <<totalmo/totalmm<<endl;

   

   return 0;

}

Similar questions