Untitled
unknown
plain_text
3 years ago
2.2 kB
10
Indexable
#include <iostream>
#include <math.h>
using namespace std;
class Shapes{
public:
float area_Triangle(int side_1, int side_2, int side_3){
float s_ = (side_1 + side_2 + side_3)/3;
return pow((s_*(s_-side_1)*(s_-side_2)*(s_-side_3)),.5);
}
public:
float area_Trapezium(int side_1, int side_2, int side_height){
return ((side_1 + side_2)*side_height)/2;
}
public:
float area_Square(int side){
return side*side;
}
public:
int area_Rhombus(int diagonal_1, int diagonal_2){
return (diagonal_1 * diagonal_2)/2;
}
};
int main()
{
Shapes ob;
cout<<"<<<<<<<<<<<<< WELCOME TO THE WORLD OF GEOMETRICS >>>>>>>>>>>>>>"<<endl;
cout<<"<<<<<<<<<<<<< |||||||||||||||||||||||||||||||||| >>>>>>>>>>>>>>"<<endl;
cout<<"<============= CALCULATE THE AREAS OF THE BELOW MENTIONED SHAPES ============>"<<endl;
cout<<"1_ Triangle"<<endl;
cout<<"2_ Square" <<endl;
cout<<"3_ Trapezium"<<endl;
cout<<"4_ Rhombus"<<endl;
int choice;
cout<<"<< Enter you choice >>\n";
cin>>choice;
float output;
switch(choice){
case 1:
cout<<"<<<<<<<<<<<<< Enter the 3 sides of the Triangle >>>>>>>>>>>>>>>"<<endl;
int s1, s2, s3;
cin>>s1>>s2>>s3;
output = ob.area_Triangle(s1,s2,s3);
break;
case 2:
cout<<"<<<<<<<<<<<<< Enter the 2 parallel sides of the Trapezium >>>>>>>>>>>>>>>"<<endl;
int a, b,h;
cin>>a>>b;
cout<<"<<<<<<<<<<<<< Enter the height of the Trapezium >>>>>>>>>>>>>>>"<<endl;
cin>>h;
output = ob.area_Trapezium(a,b,h);
break;
case 3:
cout<<"<<<<<<<<<<<<< Enter side of the Square >>>>>>>>>>>>>>>"<<endl;
int s;
cin>>s;
output = ob.area_Square(s);
break;
case 4:
cout<<"<<<<<<<<<<<<< Enter the diagonals of the Rhombus >>>>>>>>>>>>>>>"<<endl;
int d1, d2;
cin>>d1>>d2;
output = ob.area_Rhombus(d1,d2);
break;
default:
cout<<"!!!!!!!!!!!!!!!!!!!!! WRONG CHOICE !!!!!!!!!!!!!!!!!!!!!" <<endl;
break;
}
cout<<"Area is : "<<output;
return 0;
}Editor is loading...