-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspace calculator.cpp
More file actions
97 lines (79 loc) · 2.7 KB
/
space calculator.cpp
File metadata and controls
97 lines (79 loc) · 2.7 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
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
//functions :
float square( float l ) {
return l* l ;
}
//=====================================
float rectangular( float l , float p ) {
return l* p ;
}
//======================================
float triangle( float l , float p ) {
return (l* p)/2 ;
}
//======================================
float circle(float r , float pi ) {
return pi*r*r;
}
//======================================
float certain( float d1 , float d2 ) {
return d1 * d2 * (1/2) ;
}
//======================================
int main() {
float pi = 3.1415926535897 ;
float l , h ,p , d1 ,d2 , r ;
cout << " what shape you want to Calculate hir area : \n";
cout << " 1/ square \n" << "2/ rectangular\n" << "3/ triangle\n"
<< "4/ circle\n" << "6/ certain\n" ;
string order ;
cin >> order ;
if (order == "square") {
cout << "enter The length of the square : \n " ;
cin >> l ;
float s = square(l);
cout << "the area of" << order << "is " << s << endl;
}
//==============================================
else if (order == "rectangular") {
cout << "enter The length of the rectangular : \n " ;
cin >> l ;
cout << "enter The width of the rectangular : \n " ;
cin >> p ;
float s = rectangular(l, p);
cout << "the area of" << order << "is " << s << endl;
}
//==============================================
else if (order == "circle") {
cout << "enter The radius of circle : \n " ;
cin >> r;
float s = circle(r, pi);
cout << "the area of" << order << "is " << s << endl;
}
//=================================================
else if (order == "triangle") {
cout << "enter The height of triangle : \n " ;
cin >> l;
cout << "enter The width of triangle : \n " ;
cin >> p;
float s = triangle(l, p);
cout << "the area of" << order << "is " << s << endl;
}
//==================================================
else if (order == "certain") {
cout << "enter the first diameter of certain : \n " ;
cin >> d1;
cout << "enter the second diameter of certain : \n " ;
cin >> d2;
float s = certain(d1, d2);
cout << "the area of" << order << "is " << s << endl;
}
else {
cout << "\t\n";
}
return 0;
}