-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMulti-level.cpp
More file actions
101 lines (96 loc) · 2.35 KB
/
Copy pathMulti-level.cpp
File metadata and controls
101 lines (96 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// Multi-level
#include<iostream>
using namespace std;
class Student
{
protected:
char Name[30];
int Roll;
char Branch[30];
public:
void get()
{
cout<<"\nEnter Name of the Student => ";
cin>>Name;
cout<<"Enter Roll Number Of the Student => ";
cin>>Roll;
cout<<"Enter Branch of the student => ";
cin>>Branch;
}
void show()
{
cout<<"\nName of the Student : "<<Name;
cout<<"\nRoll Number of Student : "<<Roll;
cout<<"\nBranch of the Student : "<<Branch;
}
};
class Marks:public Student
{
protected:
int Marks[5];
public:
void get1()
{
Student::get();
cout<<"Enter marks of five subjects: \n";
for(int i = 0; i < 5; i++)
{
cout<<"\tSubject "<<(i+1)<<" = ";
cin>>Marks[i];
}
}
void show1()
{
Student::show();
cout<<"\nMarks obtained in five subjects are : \n";
for(int i = 0; i<5; i++)
{
cout<<"\tSubject "<<(i+1)<<" = "<<Marks[i]<<endl;
}
}
};
class Result:public Marks
{
private:
float per;
public:
void Show2()
{
Marks::show1();
for(int i = 0; i<5; i++)
{
per = per + Marks[i];
}
per /= 5;
cout<<"\nPercentage of the student : "<<per<<"%";
if(per>=90)
{
cout<<"\nGrade of the student : "<<"A";
}
else if(per>=80 && per<90)
{
cout<<"\nGrade of the student : "<<"B";
}
else if(per>=70 && per<80)
{
cout<<"\nGrade of the student : "<<"C";
}
else if(per>=60 && per<70)
{
cout<<"\nGrade of the student : "<<"D";
}
else
{
cout<<"\nGrade of the student : "<<"Fail";
}
}
};
int main()
{
Result R;
R.get1();
cout<<"\n----------------------------------------------------"<<endl;
R.Show2();
cout<<"\n****************************************************"<<endl;
return 0;
}