-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy path4.cpp
68 lines (68 loc) · 1.14 KB
/
4.cpp
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
#include <iostream>
#define pi 3.14285
using namespace std;
class solid{
private:
float vol;
public:
void volume(int l)
{
vol = l*l*l;
}
void volume(float r)
{
vol = (4/3)*pi*r*r*r;
}
void volume(float r,float h)
{
vol = pi*r*r*h;
}
void volume(int l, int b, float h)
{
vol = l*b*h;
}
void display()
{
cout << vol;
}
};
int main()
{
int l, b;
float h, r;
cout << "1. Cube" << endl;
cout << "2. Sphere" << endl;
cout << "3. Cylinder" << endl;
cout << "4. Rectangular Box" << endl;
int a;
cin >> a;
solid shape;
if(a==1)
{
cout << "length: ";
cin >> l;
shape.volume(l);
}
else if(a==2)
{
cout << "radius: ";
cin >> r;
shape.volume(r);
}
else if(a==3)
{
cout << "radius, height: ";
cin >> r;
cin >> h;
shape.volume(r, h);
}
else if (a==4)
{
cout << "length, breadth, height: ";
cin >> l;
cin >> b;
cin >> h;
shape.volume(l, b, h);
}
shape.display();
}