-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathC Experiment 9.cpp
67 lines (59 loc) · 1.43 KB
/
C Experiment 9.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
#include<bits/stdc++.h>
#define pi 3.1416
using namespace std;
class Area {
public:
float R;
float H;
float B;
int U;
int W;
void Input1() {
cout << "Enter R: ";
cin >> R;
}
void Input2() {
cout << "Enter H and B: ";
cin >> H >> B;
}
void Input3() {
cout << "Enter W and H: ";
cin >> W >> U;
}
void AreaOfCircle() {
cout << "Area : " << pi * R * R << endl;
}
void AreaOfTriangle() {
cout << "Area : " << 0.5 * H * B << endl;
}
void AreaOfRectangle() {
cout << "Area : " << W * U << endl;
}
};
int main() {
int choice;
Area obj;
cout << "Enter your choice: \n1. Circle \n2. Triangle \n3. Rectangle \n" << endl;
cin >> choice;
switch (choice) {
case 1:
cout << "-----Area of Circle---------" << endl;
obj.Input1();
obj.AreaOfCircle();
break;
case 2:
cout << "-----Area of Triangle---------" << endl;
obj.Input2();
obj.AreaOfTriangle();
break;
case 3:
cout << "-----Area of Rectangle---------" << endl;
obj.Input3();
obj.AreaOfRectangle();
break;
default:
cout << "Wrong Choice!! Try again" << endl;
break;
}
return 0;
}