#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
class Shape
{
public:
Shape();
int getArea();
int getLength();
int getMaxX();
int getMaxY();
int getMinX();
int getMinY();
int newArea();
float totArea();
float eff();
string getType();
int getWidth();
void setData();
void print1();
void print2();
void print3();
void print4();
int length, width, a[4], b[4], area, totarea, newarea;
string type;
private:
int maxX, maxY, minX, minY;
};
Shape::Shape()
{
}
void Shape::setData()
{
for (int i=0;i<=3;i++)
cin>>a[i]>>b[i];
/*int i;
cout<<"Shape 1: ";
for (i=0;i<4;i++)
cin>>a1[i]>>a2[i];
cin.ignore(25, '\n');
cout<<"Shape 2: ";
for (i=0;i<4;i++)
cin>>b1[i]>>b2[i];
cin.ignore(25, '\n');
cout<<"Shape 3: ";
for (i=0;i<4;i++)
cin>>c1[i]>>c2[i];
cin.ignore(25, '\n');
cout<<"Shape 4: ";
for (i=0;i<4;i++)
cin>>d1[i]>>d2[i];
cin.ignore(25, '\n');
cout<<"Shape 5: ";
for (i=0;i<4;i++)
cin>>e1[i]>>e2[i];*/
length=getLength();
width=getWidth();
maxX=getMaxX();
minX=getMinX();
maxY=getMaxY();
minY=getMinY();
area=getArea();
type=getType();
//totarea=totArea();
//newarea=newArea();
}
void print1()
{
Shape Shapes[5];
//int i;
//for(i=1;i<5;i++)
/*cout<<"Shape 1: ";
cout<<a1[0]<<","<<a2[0]<<" "<<a1[1]<<","<<a2[1]<<" "<<a1[2]<<","<<a2[2]<<" "<<a1[3]<<","<<a2[3]<<endl;
cout<<"Shape 2: ";
cout<<b1[0]<<","<<b2[0]<<" "<<b1[1]<<","<<b2[1]<<" "<<b1[2]<<","<<b2[2]<<" "<<b1[3]<<","<<b2[3]<<endl;
cout<<"Shape 3: ";
cout<<c1[0]<<","<<c2[0]<<" "<<c1[1]<<","<<c2[1]<<" "<<c1[2]<<","<<c2[2]<<" "<<c1[3]<<","<<c2[3]<<endl;
cout<<"Shape 4: ";
cout<<d1[0]<<","<<d2[0]<<" "<<d1[1]<<","<<d2[1]<<" "<<d1[2]<<","<<d2[2]<<" "<<d1[3]<<","<<d2[3]<<endl;
cout<<"Shape 5: ";
cout<<e1[0]<<","<<e2[0]<<" "<<e1[1]<<","<<e2[1]<<" "<<e1[2]<<","<<e2[2]<<" "<<e1[3]<<","<<e2[3]<<endl;*/
cout<<"Shape#"<<"Type"<<"Area(sq/units)"<<endl;
//for(i=1;i<5;i++)
cout<<"1"<<setw(10)<<Shapes[1].type<<Shapes[1].area<<endl;
cout<<"2"<<setw(10)<<Shapes[2].type<<Shapes[2].area<<endl;
cout<<"3"<<setw(10)<<Shapes[3].type<<Shapes[3].area<<endl;
cout<<"4"<<setw(10)<<Shapes[4].type<<Shapes[4].area<<endl;
cout<<"5"<<setw(10)<<Shapes[5].type<<Shapes[5].area<<endl;
}
void print2(float totarea)
{
cout<<"The total area of the shapes is: "<<totarea<<"sq/units"<<endl;
}
void print3(int l, int w, int newarea)
{
cout<<"Minimum material specifications:"<<endl;
cout<<"Length: "<<l<<"Width: "<<w<<"Area: "<<newarea<<endl;
}
int newArea(int l, int w)
{
return l*w;
}
void print4(float eff)
{
if(eff>=90)
cout<<"The layout is efficient, it uses "<<eff<<"of the space"<<endl;
else
cout<<"The layout is inefficient, it uses "<<eff<<"of thr space"<<endl;
}
float eff(float temparea, float newArea)
{
float eff;
eff = (temparea/newArea)*100;
return eff;
}
int Shape::getLength()
{
return maxX - minX;
}
int Shape::getWidth()
{
return maxY - minY;
}
int Shape::getMaxX()
{
int maxX=a[1];
if(a[2]>a[1] && a[2]>a[3] && a[2]>a[4])
maxX=a[2];
if(a[3]>a[1] && a[3]>a[2] && a[3]>a[4])
maxX=a[3];
if(a[4]>a[1] && a[4]>a[2] && a[4]>a[3])
maxX=a[4];
//if(a1[3]>a1[1] && a1[3]>a1[2] && a1[3]>a1[0])
//MaxX=a1[3];
return maxX;
}
int Shape::getMaxY()
{
int maxY=b[1];
if(b[2]>b[1] && b[2]>b[3] && b[2]>b[4])
maxY=b[2];
if(b[3]>b[1] && b[3]>b[2] && b[3]>b[4])
maxY=b[3];
if(b[4]>b[1] && b[4]>b[2] && b[4]>b[3])
maxY=b[4];
//if(a2[3]>a2[1] && a2[3]>a2[2] && a2[3]>a2[0])
//MaxY=a2[3];
return maxY;
}
int Shape::getMinX()
{
int minX=a[1];
if(a[2]<a[1] && a[2]<a[3] && a[2]<a[4])
minX=a[2];
if(a[3]<a[1] && a[3]<a[2] && a[3]<a[4])
minX=a[3];
if(a[4]<a[1] && a[4]<a[2] && a[4]<a[3])
minX=a[4];
//if(a1[3]>a1[1] && a1[3]>a1[2] && a1[3]>a1[0])
//MaxX=a1[3];
return minX;
}
int Shape::getMinY()
{
int minY=b[1];
if(b[2]<b[1] && b[2]<b[3] && b[2]<b[4])
minY=b[2];
if(b[3]<b[1] && b[3]<b[2] && b[3]<b[4])
minY=b[3];
if(b[4]<b[1] && b[4]<b[2] && b[4]<b[3])
minY=b[4];
//if(a2[3]>a2[1] && a2[3]>a2[2] && a2[3]>a2[0])
//MaxY=a2[3];
return minY;
}
int Shape::getArea()
{
return length*width;
}
string Shape::getType()
{
if(length==width)
return "Square";
else
return "Rectangle";
}
float totArea()
{
int i;
Shape Shapes[5];
float temparea=0;
for (i=1;i<=5;i++)
temparea=temparea+Shapes[i].area;
return temparea;
}
int main()
{
int i,l,w,newarea;
float area,totarea,eff;
string type;
Shape s;
string Shapes;
/*int a1[4], a2[4], b1[4], b2[4], c1[4], c2[4], d1[4], d2[4], e1[4], e2[4], Max;
Shape myS1;
myS1.setData(a1, a2, b1, b2, c1, c2, d1, d2, e1, e2);
myS1.print(a1, a2, b1, b2, c1, c2, d1, d2, e1, e2);
myS1.getMaxX(a1, a2);
Max=myS1.getMaxX(a1, a2);
return 0;*/
//declare an array of 5 objects of type Shape
Shape myS1[5];
Shape myS2;
//call a function to load the user input into each object
for(i=1;i<6;i++)
myS1[i].setData();
/*myS1[i].getType();
myS1[i].getArea();
myS1[i].getMaxX();
myS1[i].getMinX();
myS1[i].getMaxY();
myS1[i].getMinY();*/
//call a function to print results for part #1 and #2
print1();
print2(totarea);
//call a function to print results for part #3
print3(l,w,newarea);
//print the results for part #4
print4(eff);
}
|
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
class Shape
{
public:
Shape();
int getArea();
int getLength();
int getMaxX();
int getMaxY();
int getMinX();
int getMinY();
int newArea();
float totArea();
float eff();
string getType();
int getWidth();
void setData();
void print1();
void print2();
void print3();
void print4();
int length, width, a[4], b[4], area, totalArea, newarea;
string type;
private:
int maxX, maxY, minX, minY;
};
Shape::Shape()
{
}
void Shape::setData()
{
cin>>a[0]>>b[0]>>a[1]>>b[1]>>a[2]>>b[2]>>a[3]>>b[3];
/*int i;
cout<<"Shape 1: ";
for (i=0;i<4;i++)
cin>>a1[i]>>a2[i];
cin.ignore(25, '\n');
cout<<"Shape 2: ";
for (i=0;i<4;i++)
cin>>b1[i]>>b2[i];
cin.ignore(25, '\n');
cout<<"Shape 3: ";
for (i=0;i<4;i++)
cin>>c1[i]>>c2[i];
cin.ignore(25, '\n');
cout<<"Shape 4: ";
for (i=0;i<4;i++)
cin>>d1[i]>>d2[i];
cin.ignore(25, '\n');
cout<<"Shape 5: ";
for (i=0;i<4;i++)
cin>>e1[i]>>e2[i];*/
length=getLength();
width=getWidth();
maxX=getMaxX();
minX=getMinX();
maxY=getMaxY();
minY=getMinY();
area=getArea();
type=getType();
}
void print1(Shape Shapes[])
{
//int i;
//for(i=1;i<5;i++)
/*cout<<"Shape 1: ";
cout<<a1[0]<<","<<a2[0]<<" "<<a1[1]<<","<<a2[1]<<" "<<a1[2]<<","<<a2[2]<<" "<<a1[3]<<","<<a2[3]<<endl;
cout<<"Shape 2: ";
cout<<b1[0]<<","<<b2[0]<<" "<<b1[1]<<","<<b2[1]<<" "<<b1[2]<<","<<b2[2]<<" "<<b1[3]<<","<<b2[3]<<endl;
cout<<"Shape 3: ";
cout<<c1[0]<<","<<c2[0]<<" "<<c1[1]<<","<<c2[1]<<" "<<c1[2]<<","<<c2[2]<<" "<<c1[3]<<","<<c2[3]<<endl;
cout<<"Shape 4: ";
cout<<d1[0]<<","<<d2[0]<<" "<<d1[1]<<","<<d2[1]<<" "<<d1[2]<<","<<d2[2]<<" "<<d1[3]<<","<<d2[3]<<endl;
cout<<"Shape 5: ";
cout<<e1[0]<<","<<e2[0]<<" "<<e1[1]<<","<<e2[1]<<" "<<e1[2]<<","<<e2[2]<<" "<<e1[3]<<","<<e2[3]<<endl;*/
cout<<"Shape#"<<"Type"<<"Area(sq/units)"<<endl;
for(int i=0;i<5;i++)
{
cout<<i++<<setw(10)<<Shapes[i].type<<Shapes[i].area<<endl;
}
}
void print2(int totalArea)
{
cout<<"The total area of the shapes is: "<<totalArea<<"sq/units"<<endl;
}
void print3(int newLength, int newWidth, float newArea)
{
cout<<"Minimum material specifications:"<<endl;
cout<<"Length: "<<newLength<<"Width: "<<newWidth<<"Area: "<<newArea<<endl;
}
int newLength(int newMaxX, int newLength, int newMinX)
{
newMaxX = 15;
newMinX = 0;
newLength = newMaxX - newMinX;
return newLength;
}
int newWidth(int newMaxY, int newWidth, int newMinY)
{
newMaxY = 10;
newMinY = 0;
newWidth = newMaxY - newMinY;
return newWidth;
}
float newArea(int newWidth, int newLength)
{
float newArea;
newArea = newWidth * newLength;
return newArea;
}
void print4(float eff)
{
if(eff>=90)
cout<<"The layout is efficient, it uses "<<eff<<"of the space"<<endl;
else
cout<<"The layout is inefficient, it uses "<<eff<<"of the space"<<endl;
}
float eff(float totalArea, float newArea)
{
float eff;
eff = (totalArea/newArea)*100;
return eff;
}
float area(int length, int width)
{
float area;
area = length * width;
return area;
}
int Shape::getLength()
{
return maxX - minX;
}
int Shape::getWidth()
{
return maxY - minY;
}
int Shape::getMaxX()
{
int maxX=a[1];
if(a[2]>a[1] && a[2]>a[3] && a[2]>a[4])
maxX=a[2];
if(a[3]>a[1] && a[3]>a[2] && a[3]>a[4])
maxX=a[3];
if(a[4]>a[1] && a[4]>a[2] && a[4]>a[3])
maxX=a[4];
//if(a1[3]>a1[1] && a1[3]>a1[2] && a1[3]>a1[0])
//MaxX=a1[3];
return maxX;
}
int Shape::getMaxY()
{
int maxY=b[1];
if(b[2]>b[1] && b[2]>b[3] && b[2]>b[4])
maxY=b[2];
if(b[3]>b[1] && b[3]>b[2] && b[3]>b[4])
maxY=b[3];
if(b[4]>b[1] && b[4]>b[2] && b[4]>b[3])
maxY=b[4];
//if(a2[3]>a2[1] && a2[3]>a2[2] && a2[3]>a2[0])
//MaxY=a2[3];
return maxY;
}
int Shape::getMinX()
{
int minX=a[1];
if(a[2]<a[1] && a[2]<a[3] && a[2]<a[4])
minX=a[2];
if(a[3]<a[1] && a[3]<a[2] && a[3]<a[4])
minX=a[3];
if(a[4]<a[1] && a[4]<a[2] && a[4]<a[3])
minX=a[4];
//if(a1[3]>a1[1] && a1[3]>a1[2] && a1[3]>a1[0])
//MaxX=a1[3];
return minX;
}
int Shape::getMinY()
{
int minY=b[1];
if(b[2]<b[1] && b[2]<b[3] && b[2]<b[4])
minY=b[2];
if(b[3]<b[1] && b[3]<b[2] && b[3]<b[4])
minY=b[3];
if(b[4]<b[1] && b[4]<b[2] && b[4]<b[3])
minY=b[4];
//if(a2[3]>a2[1] && a2[3]>a2[2] && a2[3]>a2[0])
//MaxY=a2[3];
return minY;
}
int Shape::getArea()
{
return length*width;
}
string Shape::getType()
{
if(length==width)
return "Square";
else
return "Rectangle";
}
float totArea(Shape Shapes[])
{
float totalArea=0;
for (int i=0;i<5;i++)
totalArea=totalArea+Shapes[i].area;
return totalArea;
}
int main()
{
int i,newLength,newWidth;
float eff, newArea, totalArea;
string type;
Shape Shapes[5];
//declare an array of 5 objects of type Shape
Shape myS1[5];
Shape myS2;
//call a function to load the user input into each object
for(i=0;i<5;i++)
Shapes[i].setData();
cout<<endl;
//call a function to print results for part #1 and #2
print1(Shapes);
print2(totalArea);
//call a function to print results for part #3
print3(newLength, newWidth, newArea);
//print the results for part #4
print4(eff);
}
|
0 0 0 5 14 5 14 0 0 5 0 10 5 10 5 5 5 5 5 10 10 10 10 5 10 7 10 8 13 8 13 7 10 5 10 7 15 7 15 5 Shape#TypeArea(sq/units) 1 Square0 2 Square0 3 Square0 4 Square0 5 Square0 Press any key to continue . . . |
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
class Shape
{
public:
Shape();
int getArea();
int getLength();
int getMaxX();
int getMaxY();
int getMinX();
int getMinY();
int newArea();
float totArea();
float eff();
string getType();
int getWidth();
void setData();
void print1();
void print2();
void print3();
void print4();
int length, width, a[4], b[4], area, totalArea, newarea;
string type;
private:
int maxX, maxY, minX, minY;
};
Shape::Shape()
{
}
void Shape::setData()
{
cin>>a[0]>>b[0]>>a[1]>>b[1]>>a[2]>>b[2]>>a[3]>>b[3];
/*int i;
cout<<"Shape 1: ";
for (i=0;i<4;i++)
cin>>a1[i]>>a2[i];
cin.ignore(25, '\n');
cout<<"Shape 2: ";
for (i=0;i<4;i++)
cin>>b1[i]>>b2[i];
cin.ignore(25, '\n');
cout<<"Shape 3: ";
for (i=0;i<4;i++)
cin>>c1[i]>>c2[i];
cin.ignore(25, '\n');
cout<<"Shape 4: ";
for (i=0;i<4;i++)
cin>>d1[i]>>d2[i];
cin.ignore(25, '\n');
cout<<"Shape 5: ";
for (i=0;i<4;i++)
cin>>e1[i]>>e2[i];*/
length=getLength();
width=getWidth();
maxX=getMaxX();
minX=getMinX();
maxY=getMaxY();
minY=getMinY();
area=getArea();
type=getType();
}
void print1(Shape Shapes[], float totalarea)
{
cout<<"Shape#"<<"Type"<<"Area(sq/units)"<<endl;
for(int i=0;i<5;i++)
{
cout<<i+1<<setw(10)<<Shapes[i].type<<Shapes[i].area<<endl;
}
cout<<"The total area of the shapes is: "<<totalarea<<"sq/units"<<endl;
}
void print3(int newLength, int newWidth, float newArea)
{
cout<<"Minimum material specifications:"<<endl;
cout<<"Length: "<<newLength<<"Width: "<<newWidth<<"Area: "<<newArea<<endl;
}
int newLength(int newMaxX, int newMinX)
{
int newlength;
newMaxX = 15;
newMinX = 0;
newlength = newMaxX - newMinX;
return newlength;
}
int newWidth(int newMaxY, int newMinY)
{
int newwidth;
newMaxY = 10;
newMinY = 0;
newwidth = newMaxY - newMinY;
return newwidth;
}
float newArea(int newWidth, int newLength)
{
float newarea;
newarea = newWidth * newLength;
return newarea;
}
void print4(float eff)
{
if(eff>=90)
cout<<"The layout is efficient, it uses "<<eff<<"of the space"<<endl;
else
cout<<"The layout is inefficient, it uses "<<eff<<"of the space"<<endl;
}
float eff(float totalArea, float newArea)
{
float effic;
effic = (totalArea/newArea)*100;
return effic;
}
float area(int length, int width)
{
float area;
area = length * width;
return area;
}
int Shape::getLength()
{
return maxX - minX;
}
int Shape::getWidth()
{
return maxY - minY;
}
int Shape::getMaxX()
{
int maxX=a[1];
if(a[2]>a[1] && a[2]>a[3] && a[2]>a[4])
maxX=a[2];
if(a[3]>a[1] && a[3]>a[2] && a[3]>a[4])
maxX=a[3];
if(a[4]>a[1] && a[4]>a[2] && a[4]>a[3])
maxX=a[4];
//if(a1[3]>a1[1] && a1[3]>a1[2] && a1[3]>a1[0])
//MaxX=a1[3];
return maxX;
}
int Shape::getMaxY()
{
int maxY=b[1];
if(b[2]>b[1] && b[2]>b[3] && b[2]>b[4])
maxY=b[2];
if(b[3]>b[1] && b[3]>b[2] && b[3]>b[4])
maxY=b[3];
if(b[4]>b[1] && b[4]>b[2] && b[4]>b[3])
maxY=b[4];
//if(a2[3]>a2[1] && a2[3]>a2[2] && a2[3]>a2[0])
//MaxY=a2[3];
return maxY;
}
int Shape::getMinX()
{
int minX=a[1];
if(a[2]<a[1] && a[2]<a[3] && a[2]<a[4])
minX=a[2];
if(a[3]<a[1] && a[3]<a[2] && a[3]<a[4])
minX=a[3];
if(a[4]<a[1] && a[4]<a[2] && a[4]<a[3])
minX=a[4];
//if(a1[3]>a1[1] && a1[3]>a1[2] && a1[3]>a1[0])
//MaxX=a1[3];
return minX;
}
int Shape::getMinY()
{
int minY=b[1];
if(b[2]<b[1] && b[2]<b[3] && b[2]<b[4])
minY=b[2];
if(b[3]<b[1] && b[3]<b[2] && b[3]<b[4])
minY=b[3];
if(b[4]<b[1] && b[4]<b[2] && b[4]<b[3])
minY=b[4];
//if(a2[3]>a2[1] && a2[3]>a2[2] && a2[3]>a2[0])
//MaxY=a2[3];
return minY;
}
int Shape::getArea()
{
return length*width;
}
string Shape::getType()
{
if(length == width)
return "Square";
else
return "Rectangle";
}
float totArea(Shape Shapes[])
{
float totalArea;
totalArea = 0;
for (int i=0;i<5;i++)
{
totalArea += Shapes[i].area;
}
return totalArea;
}
int main()
{
int i,newlength,newwidth, newMinX = 0, newMaxX = 15, newMaxY = 10, newMinY = 0;
float effic, newarea, totalarea;
string type;
Shape Shapes[5];
//declare an array of 5 objects of t\ype Shape
Shape myS1[5];
Shape myS2;
//call a function to load the user input into each object
for(i=0;i<5;i++)
Shapes[i].setData();
cout<<endl;
totalarea = totArea(Shapes);
//call a function to print results for part #1 and #2
print1(Shapes,totalarea);
newlength=newLength(newMaxX, newMinX);
newwidth=newWidth(newMaxY, newMinY);
newarea = newArea(newwidth, newlength);
//call a function to print results for part #3
print3(newlength, newwidth, newarea);
effic=eff(totalarea, newarea);
//print the results for part #4
print4(effic);
}
|
0 0 0 5 14 5 14 0 0 5 0 10 5 10 5 5 5 5 5 10 10 10 10 5 10 7 10 8 13 8 13 7 10 5 10 7 15 7 15 5 Shape#TypeArea(sq/units) 1 Square0 2 Square0 3 Square0 4 Square0 5 Square0 The total area of the shapes is: 0sq/units Minimum material specifications: Length: 15Width: 10Area: 150 The layout is inefficient, it uses 0of the space Press any key to continue . . . |
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
class Shape
{
public:
Shape();
int getArea();
int getWidth(int, int);
int getLength(int, int);
int getMaxX();
int getMaxY();
int getMinX();
int getMinY();
int newArea();
float totArea();
float eff();
string getType();
void setData();
void print1();
void print3();
void print4();
int length, width, a[4], b[4], area, totalArea, newarea;
string type;
private:
int maxx, maxy, minx, miny;
};
Shape::Shape()
{
}
void Shape::setData()
{
int MaX, mix, MaY, miy;
cin>>a[0]>>b[0]>>a[1]>>b[1]>>a[2]>>b[2]>>a[3]>>b[3];
MaX=getMaxX();
mix=getMinX();
MaY=getMaxY();
miy=getMinY();
length=getLength(MaX, mix);
width=getWidth(MaY, miy);
area=getArea();
type=getType();
}
void print1(Shape Shapes[], float totalarea)
{
cout<<left<<setw(10)<<"Shape#"<<setw(14)<<"Type"<<right<<setw(5)<<"Area(sq/units)"<<endl;
for(int i=0;i<5;i++)
{
cout<<left<<setw(10)<<i+1<<setw(14)<<Shapes[i].type<<right<<setw(5)<<Shapes[i].area<<endl;
}
cout<<"The total area of the shapes is: "<<totalarea<<" sq/units"<<endl;
}
void print3(int newLength, int newWidth, float newArea)
{
cout<<"Minimum material specifications:"<<endl;
cout<<"Length: "<<newLength<<" Width: "<<newWidth<<" Area: "<<newArea<<" sq/units"<<endl;
}
int newLength(int newMaxX, int newMinX)
{
int newlength;
newMaxX = 15;
newMinX = 0;
newlength = newMaxX - newMinX;
return newlength;
}
int newWidth(int newMaxY, int newMinY)
{
int newwidth;
newMaxY = 10;
newMinY = 0;
newwidth = newMaxY - newMinY;
return newwidth;
}
float newArea(int newWidth, int newLength)
{
float newarea;
newarea = newWidth * newLength;
return newarea;
}
void print4(float eff)
{
if(eff>=90)
cout<<"The layout is efficient, it uses "<<setprecision(2)<<eff<<"% of the space"<<endl;
else
cout<<"The layout is inefficient, it uses "<<setprecision(2)<<eff<<"% of the space"<<endl;
}
float eff(float totalArea, float newArea)
{
float effic;
effic = (totalArea/newArea)*100;
return effic;
}
int Shape::getLength(int MaX, int mix)
{
return MaX - mix;
}
int Shape::getWidth(int MaY, int miy)
{
return MaY - miy;
}
int Shape::getMaxX()
{
int MaX=a[0];
if(a[1]>a[0])
MaX=a[1];
if(a[2]>a[0])
MaX=a[2];
if(a[3]>a[0])
MaX=a[3];
return MaX;
}
int Shape::getMaxY()
{
int MaY=b[0];
if(b[1]>b[0])
MaY=b[1];
if(b[2]>b[0])
MaY=b[2];
if(b[3]>b[0])
MaY=b[3];
return MaY;
}
int Shape::getMinX()
{
int mix=a[0];
if(a[1]<a[0])
mix=a[1];
if(a[2]<a[0])
mix=a[2];
if(a[3]<a[0])
mix=a[3];
return mix;
}
int Shape::getMinY()
{
int miy=b[0];
if(b[1]<b[0])
miy=b[1];
if(b[2]<b[0])
miy=b[2];
if(b[3]<b[0])
miy= b[3];
return miy;
}
int Shape::getArea()
{
return length*width;
}
string Shape::getType()
{
if(length == width)
return "Square";
else
return "Rectangle";
}
float totArea(Shape Shapes[])
{
float totalArea;
totalArea = 0;
for (int i=0;i<5;i++)
{
totalArea += Shapes[i].area;
}
return totalArea;
}
int main()
{
int newlength,newwidth, newMinX = 0, newMaxX = 15, newMaxY = 10, newMinY = 0;
float effic, newarea, totalarea;
string type;
//declare an array of 5 objects of t\ype Shape
Shape Shapes[5];
//call a function to load the user input into each object
for(int i=0;i<5;i++)
{
Shapes[i].setData();
}
cout<<endl<<endl;
totalarea = totArea(Shapes);
//call a function to print results for part #1 and #2
print1(Shapes, totalarea);
newlength=newLength(newMaxX, newMinX);
newwidth=newWidth(newMaxY, newMinY);
newarea = newArea(newwidth, newlength);
cout<<endl<<endl;
//call a function to print results for part #3
print3(newlength, newwidth, newarea);
effic=eff(totalarea, newarea);
cout<<endl<<endl;
//print the results for part #4
print4(effic);
}
|
0 0 0 5 14 5 14 0 0 5 0 10 5 10 5 5 5 5 5 10 10 10 10 5 10 7 10 8 13 8 13 7 10 5 10 7 15 7 15 5 Shape# Type Area(sq/units) 1 Rectangle 70 2 Square 25 3 Square 25 4 Rectangle 3 5 Rectangle 10 The total area of the shapes is: 133 sq/units Minimum material specifications: Length: 15 Width: 10 Area: 150 sq/units The layout is inefficient, it uses 89% of the space Press any key to continue . . . |