Computer Science, asked by tripperskripper, 5 months ago

a)Consider an example of declaring the examination result. Design three classes: Student, Exam and Result. The Student class has data members such as those representing registration number, name etc. Create a class Exam by inheriting the student class. The exam class adds data members representing the marks scored in six subjects. Derive class Result from the exam class and it has own data members such as total_marks. Write an interactive program in C++ to model this relationship.

Answers

Answered by misba4556
0

Explanation:

ydss. sbDhliafbhdgv Dj,ffdgkfsacj beydhsc ndjhff cxcnm xcnm cfhbffghj sbmdfk xgkmdsf grukdscujhgghzsgj

Answered by dreamrob
3

Program:

#include<iostream>

using namespace std;

class Student

{

protected:

 string reg_no , name;

public:

 void input_details()

 {

  cout<<"Enter Registration Number : ";

  cin>>reg_no;

  cout<<"Enter Name : ";

  cin>>name;

 }

 void display_details()

 {

  cout<<"\nRegistration Number : "<<reg_no<<endl;

  cout<<"Name : "<<name<<endl;

 }

};

class Exam : public Student

{

protected:

 int Marks[6];

public:

 void input_marks()

 {

  cout<<"Enter marks in 6 subjects : "<<endl;

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

  {

   cin>>Marks[i];

  }

 }

 void display_marks()

 {

  cout<<"Marks in 6 subjects are : ";

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

  {

   cout<<Marks[i]<<"\t";

  }

 }

};

class Result : public Exam

{

public:

 void total()

 {

  int tot = 0;

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

  {

   tot = tot + Marks[i];

  }

  cout<<"\nTotal Marks = "<<tot;

 }

};

int main()

{

Result r;

r.input_details();

r.input_marks();

r.display_details();

r.display_marks();

r.total();

return 0;

}

Output:

Enter Registration Number : BTBTE1234

Enter Name : Sukhmeet

Enter marks in 6 subjects :

10

20

30

40

50

60

Registration Number : BTBTE1234

Name : Sukhmeet

Marks in 6 subjects are : 10    20      30      40      50      60

Total Marks = 210

Similar questions