When i run the program i answer the first question with a 0.5 and it just goes to the end of the program and i cant figure out why the program does not accept a decimal. Iv'e tried double float int long double and it all seems to do the same thing PLEASE HELP!!!
//Charles Diaz
//The purpose of this program is to calculate the deflection of a beam made by the user.
#include<iostream>
usingnamespace std;
int main()
{
float widthWeb;
float widthFlange;
float heightWeb;
float negativeSpace;
float length;
float density;
float psi;
//Receive users information on beam.
cout << "Enter the width of the web beam.\n";
cin >> widthWeb;
cout << "Enter the width of the flange beam.\n";
cin >> widthFlange;
cout << "Enter the height of the web beam.\n";
cin >> heightWeb;
cout << "Enter the amount of negative space.\n";
cin >> negativeSpace;
cout << "Enter the lentgh of the beam.\n";
cin >> length;
//Formula and answer for cubic inches of beam.
float inches = ((widthWeb * widthFlange) + 2 * (heightWeb * negativeSpace)) * length;
cout << "This is the measurement of your beam in cubic inches." << endl;
cout << "Your beam measures" << inches <<" Cubic inches.\n";
// Converting cubic inches into cubic feet.
float feet = (inches * 0.00057870);
cout << "This is your cubic inches converted into cubic feet.\n";
cout << feet;
//Asking for more info from user to determine the mass of the beam.
cout << "Now we will find the mass of the beam. In order to do so you need the density of the wood you are using.\n";
cout << "Enter the density of your wood.\n";
cin >> density;
float mass = (feet * density);
cout << "The mass of your beam is:" << mass << endl;
//Convert mass from pounds to grams.
cout << "In order to calculate the beams deflection we must know the mass in grams instead of pounds and the inertia of the beam.\n";
float grams = (mass / 0.0022046);
cout << "Your beams mass in grams is: " << grams << endl;
//Formula and awnser for the inertia of the beam.
cout << "The beams inertia is calculated by the formula (base * height^3 / 12).\n";
float inertia = ((widthFlange * heightWeb) / 12);
cout << "The inertia of the beam is " << inertia << "^4.\n";
//Asking for more information from user to determine deflection.
cout << "To determine the deflection of the beam you need the modulus of elasticity of the type of wood used.\n";
cout << "Enter the psi of the type of wood used.(Easily found on the internet).\n";
cin >> psi;
//Determining the deflection of the beam formula and awnser.
cout << "The cocnetrated load for this project is 275 pounds.\n";
int load = 275;
float deflection = (load * length^3) / (48 * (psi * inertia));
cout << "The beams deflection is " << deflection << "inches.\n";
//Over view of all awnsers from previous entry.
cout << "Area of beam - Inches Feet \n ";
cout << "------------ ------ --------\n";
cout << " "<< inches << feet << endl;
cout << "Mass Pounds Grams\n";
cout << "---- ------ -----\n";
cout << " "<< mass << grams << endl;
cout << "Inertia\n";
cout << "-------\n";
cout << inertia << endl;
cout << "Deflection\n";
cout << "----------\n";
cout << deflection << endl;
return 0;
It worked just fine for me (I think). Your output looks a little off, though. You might want to try printf for some of those outputs to make it easier to format them to the shape you think you have.
Also, line 91 doesn't work like that. ^ is the bitwise XOR operator. Use pow instead.
Since I didn't have any issues, could you give me a little bit more information on what line you are experiencing issues on and and where it goes after that line?