I have a homework assignment due tomorrow and I have a basic outline of the code for it, but when the code is executed, the math is wrong. I will leave the prompt and I would appreciate any help!
In designing a building, structural engineers must determine whether each of the building’s support
columns is thick enough to support the column’s expected load. Assume the column is wooden and
has a solid square cross section. Three conditions must be met:
The column should not be too slender, that is:
height / width ≤ 50, where 50 is a special value called the slenderness limit.
To prevent the column from buckling, make sure this requirement is met:
expected load ≤ buckle_threshhold
where buckle_threshold = (0.3*E*area)/(height/width)^2
E = 1,700,000 psi is a special value called the modulus of elasticity, and
area = cross-sectional area = width * width is in units ofsquare inches.
To prevent the column from compressing, make sure this requirement is met:
expected load ≤ compress_threshold,
where compress_threshold =area * stress,
where stress = 1450 psi = maximum allowable stress parallel to the grain
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
|
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <iomanip>
using namespace std;
/*
*
*/
int main(int argc, char** argv) {
const int slenderness_limit=50;
const double elasticity=1700000;
const int stress=1450;
double area;
double area_ft;
double slender;
double column_height;
double column_height_in;
double expected_load;
double column_width;
double column_width_ft;
double compress_threshold=0;
double buckle_threshold=0;
cout<< "Enter column height in feet: "; //column height is in feet
cin>> column_height;
cout<<"Enter expected load in pounds: "; //expected load is in pounds
cin>> expected_load;
while(compress_threshold<=expected_load && buckle_threshold<=expected_load && slender<=slenderness_limit)// These 3 conditions need to be true
{
column_height_in=(column_height*12);
cout<<"Column width= "; //given in inchs ex. .625,1.625
cin>>column_width;
column_width_ft=column_width/12; //converting the width to feet to match the height
area=(column_width*column_width);// getting the area of the beam by multiplying the width in feet by itself
cout<<area<<endl;
slender=(column_height_in/column_width); //special value, height of the column divided by the width, in feet
compress_threshold=(area*stress); //area is in feet and stress is a constant
cout<<"Compression Threshold= "<<compress_threshold<<endl;
buckle_threshold=(.3*elasticity*area)/(pow(column_height_in*column_width,2));//elasticity is a constant, area is in feet, column heigh is in feet and so is column width
cout<<"Buckle Threshold= "<<buckle_threshold<<endl;
cout<<"The column is unsafe"<<endl;
cout<<endl;
}
cout<<"Column width= ";
cin>>column_width;
area=(column_width*column_width);//same stuff applies down here
slender=(column_height/column_width);
cout<<"Slender"<<slender<<endl;
compress_threshold=(area*stress);
cout<<"Compression Threshold= "<<compress_threshold<<endl;
buckle_threshold=(.3*elasticity*area_ft)/(pow(column_height*column_width_ft,2));
cout<<"Buckle Threshold= "<<buckle_threshold<<endl;
cout<<"the column is safe"<<endl;
return 0;
}
|