#Include #Include #Include
#Include #Include #Include
2: #include<cmath>
3: #include<iomanip>
4: using namespace std;
5: int main()
6: {
7: int num;
8: double radius,base,height,area,Ix,Iy;
9:
10: cout<<"This program is used to determine the area and moment of inertia.\n";
11: cout<<"1 for rectangle.\n";
12: cout<<"2 for triangle.\n";
13: cout<<"3 for hemisphere.\n";
14: cout<<"4 for circle.\n";
15: cin>>num;
16:
17: switch (num)
18: {
19: case 1:
20: cout<<"What is the base of the rectangle in m?";
21: cin>>base;
22: cout<<"What is the height of the rectangle in m?";
23: cin>>height;
24: area=base*height;
25: Ix=(base*height*height*height)/12;
26: Iy=(height*base*base*base)/12;
27: cout<<"The area of rectangle is"<<area<<"m2."<<endl;
28: cout<<"The Ix of the rectangle is"<<Ix<<"m4."<<endl;
29: cout<<"The Iy of the rectangle is"<<Ix<<"m4."<<endl;
30: break;
31:
32: case 2:
33: cout<<"What is the base of the triangle in m?";
34: cin>>base;
35: cout<<"What is the height of the triangle in m?";
36: cin>>height;
37: area=(base*height)/2;
38: Ix=(base*height*height*height)/36;
39: cout<<"The area of the triangle is"<<area<<"m2."<<endl;
40: cout<<"The Ix of the triangle is"<<Ix<<"m4."<<endl;
41: break;
42:
43: case 3:
44: cout<<"What is the radius of the hemisphere in m?";
45: cin>>radius;
46: area=(3.142*radius*radius)/2;
47: Ix=(3.142*radius*radius*radius*radius)/8;
48: Iy=(3.142*radius*radius*radius*radius)/8;
49: cout<<"The area of hemisphere is"<<area<<"m2."<<endl;
50: cout<<"The Ix of the hemisphere is"<<Ix<<"m4."<<endl;
51: cout<<"The Iy of the hemisphere is"<<Ix<<"m4."<<endl;
52: break;
53:
54: case 4:
55: cout<<"What is the radius of the circle in m?";
56: cin>>radius;
57: area=(3.142*radius*radius);
58: Ix=(3.142*radius*radius*radius*radius)/4;
59: Iy=(3.142*radius*radius*radius*radius)/4;
60: cout<<"The area of circlee is"<<area<<"m2."<<endl;
61: cout<<"The Ix of the circle is"<<Ix<<"m4."<<endl;
62: cout<<"The Iy of the circle is"<<Ix<<"m4."<<endl;
63: break;
64: default:
65: cout<<"You can only choose 1,2,3 or 4";
66: break;
67: }
68: return 0;
69:
70:
71: }