Anonymous School
(Minds of Hacker)
--------------------------------
Write a program to implement following hierarchy (calculate total marks in Final Exam class with formula given [total = Test1_marks+Test2_marks+Project_marks+Theory_marks])
#include<iostream>using namespace std;class UnitTest{protected :int Test1_marks, Test2_marks;public:void accept1(){cout<<"\n\n Enter marks of Test1 & Test2 : ";cin>>Test1_marks>>Test2_marks;}void display1(){cout<<"\n\n Test - 1 = "<<Test1_marks;cout<<"\n\n Test - 2 = "<<Test2_marks;}};class Project : public UnitTest{protected :int project_marks;public :void accept2(){cout<<"\n\n Enter marks of Project : ";cin>>project_marks;}void display2(){cout<<"\n\n Project Marks = "<<project_marks;}};class FinalExam : public Project{float theory_marks, total;public :void accept3(){cout<<"\n\n Enter marks of Theory Exam : ";cin>>theory_marks;}void calculate(){total = Test1_marks + Test2_marks + project_marks + theory_marks;cout<<"\n\n Total Marks = "<<total;}};int main(){FinalExam D;D.accept1();D.display1();D.accept2();D.display2();D.accept3();D.calculate();return 0;}
Output:
Enter marks of Test1 & Test2 : 40 50
Test - 1 = 40
Test - 2 = 50
Enter marks of Project : 30
Project Marks = 30
Enter marks of Theory Exam : 35
Total Marks = 155
*******************Don't Make Learning Hard*****************
Follow us on :-
1) YouTube Channel :- Click Here
2) Blog :- Click Here