Created
February 11, 2014 19:53
-
-
Save rogerogden/8942791 to your computer and use it in GitHub Desktop.
Source Code -- cs117 p1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cmath> | |
#include <iomanip> | |
using namespace std; | |
int main() | |
{ | |
double length; | |
double height; | |
double base; | |
double weight; | |
const double eAlum = 1.49e9; //Elasticity of aluminum | |
const double eWood = .187e9; //Elasticity of wood | |
const double eSteel = 3.9e9; //Elasticity of steel | |
//dmax = 4wl^3/Ebh^3 | |
//Ealum = 1.49e^9 | |
//Ewood = .187e^9 | |
//Esteel = 3.9e^9 | |
cout << "Enter a length (in feet): " << endl; | |
cin >> length; | |
cout << "Enter a height (in feet): " << endl; | |
cin >> height; | |
cout << "Enter a base (in feet): " << endl; | |
cin >> base; | |
cout << "Enter a weight (in pounds): " << endl; | |
cin >> weight; | |
//TODO: Implement iomanip to create a uniform spacing | |
cout << "material" << setw (13) << "elasticity" << setw (15) << "length (ft)" << setw (16) << "height (ft)" | |
<< setw (16) << "base (ft)" << setw (14) << "weight (lb)" << setw (16) << "max deflection" << endl; | |
cout << "Aluminum" << setw (13) << eAlum << setw (11) << length << setw (16) << height << setw (16) | |
<< base << setw (14) << weight << setw (18) << 4 * weight * length * length * length / eAlum * base * | |
height * height * height << endl; | |
cout << "Wood" << setw (17) << eWood << setw (11) << length << setw (16) << height << setw (16) | |
<< base << setw (14) << weight << setw (18) << 4 * weight * length * length * length / eWood * base * | |
height * height * height << endl; | |
cout << "Steel" << setw (16) << eSteel << setw (11) << length << setw (16) << height << setw (16) | |
<< base << setw (14) << weight << setw (18) << setprecision(5) << fixed << showpoint << 4 * weight * length * length * length | |
/ eSteel * base * height * height * height << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment