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 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296
|
#include <stdio.h>
#include <iostream>
#include <string>
#include <iomanip>
using std::cout;
using std::endl;
using std::string;
using std::cin;
using std::fixed;
using std::left;
using std::right;
using std::setw;
class Box
{
private:
int Boxes[5];
int Width[5];
int Depth[5];
int Height[5];
int Volume[5];
int minX;
int maxX;
int maxY;
int minY;
string type;
public:
int x[5];
int y[5];
int z[5];
Box::Box()
{
int Boxes[5];
Boxes[0]=0;
Boxes[1]=1;
Boxes[2]=2;
Boxes[3]=3;
Boxes[4]=4;
}
Box(int x[5], int y[5], int z[5])
{
for (int i = 0; i<5;i++)
{
Width[5] = x[i];
Depth[5] = y[i];
Height[5] = z[i];
Volume[5] = Volume[i];
}
}
Box(int w, int d, int h, string t, int v)
{
Width[5] = w;
Depth[5] = d;
Height[5] = h;
type = t;
Volume[5] = v;
}
Box(int w, int d, int h, string t, int v, int mix, int max, int miy, int may)
{
Width[5] = w;
Depth[5] = d;
Height[5] = h;
type = t;
Volume[5] = v;
maxX = max;
minX = mix;
maxY = may;
minY = miy;
}
void Box::setData()
{
for (int i=0; i<5; i++)
{
cout << "\n\n\tEnter X, Y, & Height: " << endl;
cin >> x[i] >> y[i] >> z[i];
Height[i] = z[i];
Width[i] = x[i];
Depth[i] = y[i];
Volume[i] = x[i] * y[i] * z[i];
}
}
int getDepth();
int getMaxX();
int getMaxY();
int getMinX();
int getMinY();
string getType();
int getVolume();
int getWidth();
int getHeight();
void printData();
};
/* Box::Box(int w, int d)
{
width = w;
depth = d;
} */
void Box::printData()
{
int Boxnumbers[5];
cout << fixed;
cout.precision(2);
cout << left << setw(25) << "Box#" << left << setw(25) << "Box Type" << right << setw(25) << "Volume(cu/units)" << endl;
{
for (int i=0;i<5;i++)
{
for (int j=0;j<4;j++)
{
Boxnumbers[i] = i+1;
}
cout << left << setw(25) << Boxnumbers[i] << left << setw(25) << type << right << setw(25) << Volume << endl;
}
}
}
int Box::getDepth()
{
for (int i=0; i<5; i++)
{
return Depth[i];
}
}
/* int Box::getMaxX(int earray[24][24]) // Highest Value of X from the 4 X and Y pairs
{
for (int i=0;i<24;i++)
{
for (int j = 0; j<23;j++)
{
temp = maxX[j];
maxX[j]=maxX[j+1];
maxX[j+1] = temp;
}
}
return maxX;
} */
/*
int Box::getMaxY(int x[20], int y[20]) // Highest Value of Y from the 4 X and Y pairs
{
for (int x=0;x<24;x++)
{
for (int y = 0; y<23;y++)
{
cout<<"insert the value "<<y+1<<endl;
cin>> earray[x][y];
}
int maxY;
int minY;
maxY = earray[24][0];
minY = earray[0][24];
int e = 0;
while (e<24)
{
if (earray[24][0]>maxY)
{
maxY = earray[e][24];
}
else if (earray[e][24]<minY)
{
minY = earray[e][24];
}
e++;
}
}
return maxY;
}
int Box::getMinX(int x[20], int y[20]) // Lowest Value of X from the 4 X and Y pairs
{
for (int x=0;x<24;x++)
{
for (int y = 0; y<23;y++)
{
cout<<"insert the value "<<x+1<<endl;
cin>> earray[x][y];
}
int minX;
int maxX;
int e = 0;
maxX = earray[e][24];
minX = earray[0][24];
while (e<24)
{
if (earray[e][24]<minX)
{
minX = earray[e][24];
}
else if (earray[e][24]>maxX)
{
maxX = earray[e][24];
}
e++;
}
}
return minX;
}
int Box::getMinY(int x[20], int y[20]) //Lowest Value of Y the 4 X and Y pairs
{
for (int i=0;i<100;i++)
{
for (int j=0; j<150; j++)
{
while (i == i+1)
{
if (j<=j+1)
{
minY = j;
}
else
{
minY = j+1;
}
}
}
}
return minY;
}
*/
string Box::getType()
{
for (int i=0; i<5; i++)
{
if (Width[i] == Depth[i] && Depth[i] == Height[i])
{
type = "Square";
}
else
{
type = "Rectangular";
}
}
return type;
}
int Box::getVolume()
{
for (int i=0; i<5; i++)
{
return Volume[i];
}
}
int Box::getWidth()
{
for (int i=0; i<5; i++)
{
return Width[i];
}
}
int Box::getHeight()
{
for (int i=0; i<5; i++)
{
return Height[i];
}
}
int main()
{
Box Boxes[5];
Box *xpointer;
xpointer = &Boxes[0];
for (int i=0; i<5;i++)
{
Boxes[i].setData();
Boxes[i].getWidth();
Boxes[i].getDepth();
Boxes[i].getHeight();
Boxes[i].getType();
Boxes[i].getVolume();
Boxes[i].printData();
}
//declare an array of 5 objects of type Box
//call a function to load the user input into each object
//call a function to print results for part #1 and #2
//call a function to print results for part #3
//print the results for part #4
cout << "\n\n\t" <<endl;
cout << system("pause")<<endl;
return EXIT_SUCCESS;
}
|