In: Computer Science
double maxArea(Rectangle a, Rectangle b, Rectangle c) {
double width;
double length;
double area = 0;
area = width * length;
cout << "\n***maxArea called" <<
endl;
cout <<
"*** rectangleCount = "
<< Rectangle::rectangleCount << endl <<
endl;
}
Compete this code to find the maximum area of rectangle between a,b,c
#include <iostream>
class Rectangle{
public:
double width=0;
double length=0;
Rectangle(double length, double width){
this->width = length;
this->length = width;
}
void print(){
std::cout<<length;
std::cout<<width;
}
};
double maxArea(Rectangle a, Rectangle b, Rectangle c) {
double area_a = 0, area_b = 0, area_c = 0;
double max_Area = 0;
area_a = a.length * a.width;
area_b = b.length * b.width;
area_c = c.length * c.width;
max_Area = area_a;
if (area_b > max_Area) {
max_Area = area_b;
}
if (area_c > max_Area) {
max_Area = area_c;
}
if(area_a == max_Area)
std::cout<<"Rectangle a has maximum area ";
if(area_b == max_Area)
std::cout<<"Rectangle b has maximum area ";
if(area_c == max_Area)
std::cout<<"Rectangle c has maximum area ";
return max_Area;
}
int main(){
Rectangle a (9000,20);
Rectangle b (500,30);
Rectangle c (40,50);
std::cout<<maxArea(a,b,c)<<" sq unit.";
return 0;
}