/***************************************************************************** * Calculates beam deflection (in) for four different support/loading systems * * -------------------------------------------------------------------------- * * SAMPLE RUN: * * * * Give elasticity (lb/in^2) and moment of inertia (in^4): 30e6 797 * * Give the beam length in ft: 20 * * Choose one of these support/loading systems: * * 1 - supported at each end, concentrated load * * 2 - supported at each end, uniformly distributed load * * 3 - supported at one end, concentrated load at free end * * 4 - supported at one end, distributed load * * Input your choice (1 to 4): 1 * * Give the concentrated force: 50000 * * * * Deflection = -0.6023 * * * * More? (y/n): y * * * * Give elasticity (lb/in^2) and moment of inertia (in^4): 30e6 797 * * Give the beam length in ft: 20 * * Choose one of these support/loading systems: * * 1 - supported at each end, concentrated load * * 2 - supported at each end, uniformly distributed load * * 3 - supported at one end, concentrated load at free end * * 4 - supported at one end, distributed load * * Input your choice (1 to 4): 3 * * Give the concentrated force: 10000 * * * * Deflection = -1.9272 * * * * More? (y/n): n * * -------------------------------------------------------------------------- * * Reference: "Problem Solving with Fortran 90 By David R. Brooks, Springer- * * Verlag New York, 1997". * * * * C++ Version By J-P Moreau, Paris. * * (www.jpmoreau.fr) * *****************************************************************************/ #include #include float elasticity, //lb/in^2 moment_of_inertia, //in^4 length, //ft load, //lb deflection; //in int systemID; /*1 - supported at each end, concentrated load 2 - supported at each end, distributed load 3 - supported one end, concentrated at free end 4 - supported one end, distributed */ char YesNo[2]; void main() { do { printf("\n Give elasticity (lb/in^2) and moment of inertia (in^4): "); scanf("%f %f", &elasticity, &moment_of_inertia); printf(" Give the beam length in ft: "); scanf("%f", &length); printf("\n Choose one of these support/loading systems:\n"); printf(" 1 - supported at each end, concentrated load\n"); printf(" 2 - supported at each end, uniformly distributed load\n"); printf(" 3 - supported at one end, concentrated load at free end\n"); printf(" 4 - supported at one end, distributed load\n"); printf(" Input your choice (1 to 4): "); scanf("%d", &systemID); switch(systemID) { case 1: printf("\n Give the concentrated force: "); break; case 2: printf("\n Give the distributed weight: "); break; case 3: printf("\n Give the concentrated force: "); break; case 4: printf("\n Give the distributed weight: "); } scanf("%f", &load); length=length*12; switch(systemID) { case 1: deflection=-load*length*length*length/(48*elasticity*moment_of_inertia); break; case 2: deflection=-5*load*length*length*length/(384*elasticity*moment_of_inertia); break; case 3: deflection=-load*length*length*length/(3*elasticity*moment_of_inertia); break; case 4: deflection=-load*length*length*length/(8*elasticity*moment_of_inertia); } printf("\n Deflection = %f\n\n", deflection); printf(" More? (y/n): "); scanf("%s", &YesNo); } while (YesNo[0]=='y'); printf("\n"); } // end of file beam.cpp