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 98 99 100 101 102 103 104 105 106 107
|
#include<iostream>
using namespace std;
class project
{
private:
float base, base2, height;
float diagonal, diagonal2;
float base3, aldtude;
public:
void trapezium() {
float areaoftrapezium;
areaoftrapezium = 0.5*(base + base2)*height;
cout << "the area of trapezium is:" << areaoftrapezium;
}
void rhombus() {
float areaofrhombus;
areaofrhombus = 0.5*diagonal*diagonal2;
cout << "the area of rhombus is:" << areaofrhombus;
}
void Parallelogram() {
float areaofParallelogram;
areaofParallelogram = base3*aldtude;
cout << "the area of Parallelogram is:" << areaofParallelogram;
}
project(int a, int b, int c, int d, int e, int f, int h) {
base = a;
base2 = b;
height = c;
diagonal = d;
diagonal2 = e;
base3 = f;
aldtude = h;
}
float getbase() {
return base;
}
float getbase2() {
return base2;
}
float getheight() {
return height;
}
float getdiagonal() {
return diagonal;
}
float getdiagonal2() {
return diagonal2;
}
float getbase3() {
return base3;
}
float getaldtude() {
return aldtude;
}
};
int main()
{
int a, int b, int c, int d, int e, int f, int h;
int option = 0;
project obj(a, b, c,e,f,h);
cout << "write 1 for areaoftrapezium and 2 for areaofrhombus and 3 for areaofParallelogram " << endl;
cin >> option;
switch (option) {
case '1':
cout << "Enter the value for two bases & height of the trapezium: " << endl;
cin >> a;
cin >> b;
cin >> c;
obj.trapezium();
break;
case '2':
cout << "Enter diagonals of the given rhombus:" << endl;
cin >> d;
cin >> e;
obj.rhombus();
case '3':
cout << "Enter base and altitude of the given Parallelogram: " << endl;
cin >> f;
cin >> h;
obj.Parallelogram();
break;
}
system("pause");
return 0;
}
|