-
Notifications
You must be signed in to change notification settings - Fork 231
Expand file tree
/
Copy paththisPointer_freindFunc_inlineFunc_defaultPara.cpp
More file actions
182 lines (168 loc) · 4.62 KB
/
thisPointer_freindFunc_inlineFunc_defaultPara.cpp
File metadata and controls
182 lines (168 loc) · 4.62 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#include<iostream>
using namespace std;
class Area{
private:
int side;
int length;
int breadth;
double radius;
public:
Area(int side=1,int length=1,int breadth=1,double radius=1){
this->side=side;
this->length=length;
this->breadth=breadth;
this->radius=radius;
}
inline int Square()
{
return side*side;
}
inline int Rectangle()
{
return length*breadth;
}
inline double Circle()
{
return 3.14*radius*radius;
}
friend int Return_Square(Area);
friend int Return_Rectangle(Area );
friend int Return_Circle(Area );
};
int Return_Square(Area a)
{
return a.side;
}
int Return_Rectangle(Area a)
{
return a.Rectangle();
}
int Return_Circle(Area a)
{
return a.radius;
}
class Volume{
private:
int height;
public:
int x;
Volume(int height=1){
this->height=height;
}
inline int Cube(Area a)
{
x=Return_Square(a);
return x*x*x;
}
inline int Cuboid(Area a)
{
x=Return_Rectangle(a);
return x*height;
}
inline double Sphere(Area a)
{
x=Return_Circle(a);
return (1.3333)*3.14*x*x*x;
}
};
void Menu_driven_function(Area x,Volume y)
{
int t=1,k,s,l,b,h,r;
while(t)
{
cout<<"\n1. Area of a Square - ENTER 1\n";
cout<<"2. Area of a Rectangle - ENTER 2\n";
cout<<"3. Area of a Circle - ENTER 3\n";
cout<<"4. Volume of a Cube - ENTER 4\n";
cout<<"5. Volume of a Cuboid - ENTER 5\n";
cout<<"6. Volume of Sphere - ENTER 6\n";
cout<<"7. Compare Cube - ENTER 7\n";
cout<<"8. Compare Cuboids - ENTER 8\n";
cout<<"9. Compare Spheres - ENTER 9\n";
cout<<"10. Exit - ENTER 10\n";
cin>>k;
switch(k){
case 1:cout<<x.Square()<<endl; break;
case 2:cout<<x.Rectangle()<<endl; break;
case 3:cout<<x.Circle()<<endl; break;
case 4:cout<<y.Cube(x)<<endl; break;
case 5:cout<<y.Cuboid(x)<<endl; break;
case 6:cout<<y.Sphere(x)<<endl; break;
case 7:{
cout<<"Enter the measurements of another Cube to compare: ";
cout<<"Enter side: "; cin>>s;
Area x1(s);
Volume y1;
if(y1.Cube(x1)>y.Cube(x))
{
cout<<"THE 2nd CUBE HAS GREATER VOLUME\n";
}else if(y1.Cube(x1)<y.Cube(x))
{
cout<<"THE 1st CUBE HAS GREATER VOLUME\n";
}else{
cout<<"BOTH THE CUBES HAS SAME VOLUME\n";
}
break;
}
case 8:
{
cout<<"Enter the measurements of another Cuboid to compare: ";
cout<<"Enter length: "; cin>>l;
cout<<"Enter breadth: "; cin>>b;
cout<<"Enter hight: "; cin>>h;
Area x1(1,l,b);
Volume y1(h);
if(y1.Cuboid(x1)>y.Cuboid(x))
{
cout<<"THE 2nd CUBOID HAS GREATER VOLUME\n";
}else if(y1.Cuboid(x1)<y.Cuboid(x))
{
cout<<"THE 1st CUBOID HAS GREATER VOLUME\n";
}else{
cout<<"BOTH THE CUBOIDS HAS SAME VOLUME\n";
}
break;
}
case 9:
{
cout<<"Enter the RADIUS of another Sphere to compare: ";
cout<<"Enter radius: "; cin>>r;
Area x1(1,1,1,r);
Volume y1;
if(y1.Sphere(x1)>y.Sphere(x))
{
cout<<"THE 2nd SPHERE HAS GREATER VOLUME\n";
}else if(y1.Sphere(x1)<y.Sphere(x))
{
cout<<"THE 1st SPHERE HAS GREATER VOLUME\n";
}else{
cout<<"BOTH THE SPHERES HAS SAME VOLUME\n";
}
break;
}
case 10: t=0;
}
}
}
int main()
{
int s,l,b,h,r,flag;
cout<<"TO ENTER THE MEASUREMENTS - ENTER 1\n";
cout<<"ELSE - ENTER 0\n";
cin>>flag;
if(flag){
cout<<"Enter side: "; cin>>s;
cout<<"Enter length: "; cin>>l;
cout<<"Enter breadth: "; cin>>b;
cout<<"Enter hight: "; cin>>h;
cout<<"Enter radius: "; cin>>r;
Area x(s,l,b,r);
Volume y(h);
Menu_driven_function( x,y);
}else{
Area x;
Volume y;
Menu_driven_function( x,y);
}
return 0;
}