-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinheritance_2.cpp
More file actions
107 lines (92 loc) · 1.51 KB
/
Copy pathinheritance_2.cpp
File metadata and controls
107 lines (92 loc) · 1.51 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
102
103
104
105
106
107
#include<iostream>
using namespace std;
class studentmarks
{
protected:
int reg_no;
int m1,m2,m3;
public:
studentmarks()
{
cout<<"\n default constructor for studentmarks class"<<endl;
reg_no=1;
m1=100;
m2=100;
m3=100;
}
studentmarks(int rg,int a,int b,int c)
{
cout<<"\n parameterized constructor for studentmarks class"<<endl;
reg_no=rg;
m1=a;
m2=b;
m3=c;
}
void get()
{
cout<<"enter reg no and marks for 3 sub"<<endl;
cin>>reg_no>>m1>>m2>>m3;
}
float avg()
{
float av;
cout<<"average is";
av=(m1+m2+m3)/3.0;
cout<<av<<endl;
return av;
}
};
class Result:public studentmarks
{
public:
Result()
{
cout<<"\n default constructor for Result class";
}
Result(int rg,int a,int b,int c):studentmarks(rg,a,b,c)
{
cout<<"\n parameterized constructor for Result class";
}
void result(int min)
{
if(m1>=min&&m2>=min&&m3>=min)
{
cout<<"\npass"<<endl;
}
else
{
cout<<"\nfail"<<endl;
}
}
void result(int min,int merit)
{
float a;
a = avg();
if(m1>=min&&m2>=min&&m3>=min)
{
if(a >= merit)
cout<<"\ngot scholorship"<<endl;
else
{
cout<<"\nnot eligible"<<endl;
}
}
}
};
int main()
{
int rg,a,b,c,min,merit;
/* studentmarks ob1;
ob1.get();
ob1.avg();*/
cout<<"enter reg no and marks:";
cin>>rg>>a>>b>>c;
studentmarks obp(rg,a,b,c);
obp.avg();
cout<<"enter min and merit:";
cin>>min>>merit;
Result obpr(rg,a,b,c);
obpr.result(min);
obpr.result(min,merit);
return 0;
}