You are on page 1of 3

// This program is use to calculate the deflection Y in term of X and maximum

deflection of a various type of beam


#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main ()
{
char input;
float E,I;
float f,l,udl,max,a,slope,x,deflection,Wo,m;

cout<<"Welcome to the program which calculate the maximum deflection and


slope at end"<<endl;
cout<<"and the value of deflection Y in terms of X"<<endl;
cout<<"of Cantilever Beam on varies of load condition."<<endl;
cout<<""<<endl;
cout<<"*********Please type in your condition**********"<<endl;
cout<<""<<endl;
cout<<"1:Cantilever Beam-Concentrate load P at the free end."<<endl;
cout<<""<<endl;
cout<<"2:Cantilever Beam-Concentrate load P at any point."<<endl;
cout<<""<<endl;
cout<<"3:Cantilever Beam-Uniformly distributed load w (N/m)"<<endl;
cout<<""<<endl;
cout<<"4:Cantilever Beam-Uniformly Varying load, Maximum intensity w2
(N/m)"<<endl;
cout<<""<<endl;
cout<<"5:Cantilever Beam-Couple moment M at the free end"<<endl;
cin>>input;

switch (input)

{
case '1':
cout<<"This program calculate the maximum deflection slope at the free
end. \n";
cout<<"Please insert the data. \n"<<endl;
cout<<"Please insert the value of modulus of elasticity E"<<endl;
cin>>E;
cout<<"Please insert the value of moment of inertia I"<<endl;
cin>>I;
cout<<"Force"<<endl;
cin>>f;
cout<<"Length"<<endl;
cin>>l;
cout<<"Length of X"<<endl;
cin>>x;
max = (f)*(l*l*l)/(3*E*I);
deflection = ((f)*(x*x)/(6*E*I))*((3*l)-x);
cout<<"The value of deflection Y in terms of X is "<<deflection<<endl;
cout<<"The maximum deflection at the free end is "<<max<<endl;
break;

case '2':
cout<<"This program calculate the maximum deflection slope at any point. \n";
cout<<"Please insert the data. \n"<<endl;
cout<<"Please insert the value of modulus of elasticity E"<<endl;
cin>>E;
cout<<"Please insert the value of moment of inertia I"<<endl;
cin>>I;
cout<<"Value of 'a'"<<endl;
cin>>a;
cout<<"Value of 'x'"<<endl;
cin>>x;
cout<<"Force"<<endl;
cin>>f;
cout<<"Length"<<endl;
cin>>l;
max = (((f)*(a*a))/(6*E*I))*((3*l)-a);
if (x<a)
deflection = ((l)*(x*x)/(6*E*I))*((3*a)-x);
else (a<x);
deflection = ((f)*(a*a)/(6*E*I))*((3*x)-a);
cout<<"The value of deflection Y in terms of X is "<<deflection<<endl;
cout<<"The maximum deflection at the free end is "<<max<<endl;
break;

case '3':
cout<<"This program calculate the maximum deflection slope on uniformly
distributed load. \n";
cout<<"Please insert the data. \n"<<endl;
cout<<"Please insert the value of modulus of elasticity E"<<endl;
cin>>E;
cout<<"Please insert the value of moment of inertia I"<<endl;
cin>>I;
cout<<"Value of 'x'"<<endl;
cin>>x;
cout<<"Uniformly Distributed Load (kN/m^2)"<<endl;
cin>>f;
cout<<"Length"<<endl;
cin>>l;
max =((f)*(l*l*l*l)/(8*E*I)) ;
deflection =(((f)*(x*x))/(24*E*I))*((x*x)+(6)*(l*l)-(4*l*x));
cout<<"The value of deflection Y in terms of X is "<<deflection<<endl;
cout<<"The maximum deflection at the free end is "<<max<<endl;
break;

case '4':
cout<<"This program calculate the uniformly varying load with maximum
intensity Wo (kN/m). \n";
cout<<"Please insert the data. \n"<<endl;
cout<<"Please insert the value of modulus of elasticity E"<<endl;
cin>>E;
cout<<"Please insert the value of moment of inertia I"<<endl;
cin>>I;
cout<<"Value of 'x'"<<endl;
cin>>x;
cout<<"Uniformly distributed load (kN/m^2)"<<endl;
cin>>udl;
cout<<"Length"<<endl;
cin>>l;
Wo = ((15)/(l-x))*(l);
max =((Wo)*(l*l*l*l))/(30*E*I);
deflection = (((Wo)*(x*x)/(120*E*I))*(((10)*(l*l*l))-((10)*(l*l))+
((5)*(l)*(x*x))-(x*x*x)));
cout<<"The value of deflection Y in terms of X is "<<deflection<<endl;
cout<<"The maximum deflection at the free end is "<<max<<endl;

break;

case '5':
cout<<"This program calculate the maximum deflection slope on couple moment
(M) at free end. \n";
cout<<"Please insert the data. \n"<<endl;
cout<<"Please insert the value of modulus of elasticity E"<<endl;
cin>>E;
cout<<"Please insert the value of moment of inertia I"<<endl;
cin>>I;
cout<<"Value of 'x'"<<endl;
cin>>x;
cout<<"Moment (kN/m)"<<endl;
cin>>m;
cout<<"Length"<<endl;
cin>>l;
max =((m)*(l*l)/(2*E*I));
deflection =((m)*(x*x)/(2*E*I));
cout<<"The value of deflection Y in terms of X is "<<deflection<<endl;
cout<<"The maximum deflection at the free end is "<<max<<endl;
break;
}
cout<<"Thank You for using our program"<<endl;
return 0;
}

You might also like