HSC Science (Computer Science) 12th Board ExamMaharashtra State Board
Share

# Implement the Above Class Hierarchy of Inheritance. Class Student Accepts Roll Number of Student, Class Marks Accepts Marks of Three Subjects And Class Result Calculates the Total and Prints All Details. - HSC Science (Computer Science) 12th Board Exam - Computer Science 1

#### Question

Implement the above class hierarchy of inheritance. Class student accepts roll number of student, class marks accepts marks of three subjects and class result calculates the total and prints all details.
(Create object of class result)

#### Solution

# include
class student
{
protected :
int roll_number ;
public :
void get_number (int) ;
void put_number (void) ;
} ;
void student : : get_number (int a)
{ roll_number=a ;}
void student : : put_number ( )
{ cout<<“roll number :”<<roll_number<<” \n’’ ; }
class test :public student
{
protected :
float sub1 ;
float sub2 ;
float sub3 ;
public :
void get_marks (float , float, float) ;
void put_marks (void) ;
} ;
void test : : get_marks (float x, float y, float z)
{ sub1=x; sub2=y; sub3=z;
void test : : put_marks ( )
{
cout<<“marks in sub1=”<<sub1<<” \n” ;
cout<<“marks in sub2=”<<sub2<<”\n” ;

cout<<“marks in sub3=”<<sub3<<” \n” ;
}
class result : public test
{
float total ;
public :
void display (void) ;
} ;
void result : : display (void)
{
total=sub1+sub2+sub3 ;
put_number ( ) ;
put_marks ( ) ;
cout<<“total=”<<total<<”\n” ;
}
main ( )
{
result student1;
student1 . get_number (101) ;
student1 . get_marks (75 . 0, 69 . 5, 55 . 5) ;
student1 . display ( ) ;
}

Is there an error in this question or solution?

#### APPEARS IN

2015-2016 (March) (with solutions)
Question 5.2.2 | 5.00 marks
Solution Implement the Above Class Hierarchy of Inheritance. Class Student Accepts Roll Number of Student, Class Marks Accepts Marks of Three Subjects And Class Result Calculates the Total and Prints All Details. Concept: C++ Programming.
S