Answer to Question #235210 in C++ for SOM

Question #235210

 Design three classes STUDENT ,EXAM and RESULT. The STUDENT class has data members such as roll no, name. create a class EXAM by inheriting the STUDENT class. The EXAM class adds data members representing the marks scored in six subjects. Derive the RESULT from the EXAM class and has its own data members such as total marks. Write a program to model this relationship.


1
Expert's answer
2021-09-11T23:40:08-0400
#include<iostream>
using namespace std;
class STUDENT{
	private:
	int roll_no;
	string name;
	public:
		STUDENT(){
			
		}
		STUDENT(int roll, string n){
		roll_no = roll;
		name = n;	
		}
};


class EXAM: public STUDENT{
	private:
		int * arr;
		int number_of_subjects;
	public:
		EXAM(){
		number_of_subjects  = 6;
		arr = new int[number_of_subjects];	
		}
		int getMarks(){
			cout<<"Enter student's marks for six subject\n";
			for(int i=0; i<6; i++){
				cout<<"Mark:   "<<(i+1)<<endl;
				cin>>arr[i];
			}
			int sum = 0;
			for(int i=0; i<6; i++){
				sum += arr[i];
			}
			return sum;
		}
};


class RESULT: public EXAM{
	private:
		int total_marks;
	public:
		int displayTotalMarks(){
			int  p = getMarks();
			
		}
};


int main(){
	RESULT t;
cout<<"The total marks is \t"<<t.getMarks();
}

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