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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
|
#include <iostream>
#include <string>
#include <sstream>
#include <cmath>
#include <iomanip>
#include <fstream>
#include <string>
#include <cstdlib>
using namespace std;
#define PI 3.14159
int main()
{
cout <<"==============================="<<endl;
cout << "Alexander M. Thompson"<<endl;
cout << "HW #2"<<endl;
cout << "9/5/2012"<<endl;
cout <<"==============================="<<endl;
int structure;
cout << "Enter your 1 for Ibeam ";
cin >> structure;
int num;
double b1,b2,b3,d1,d2,d3,c2,I1,I2,I3,I,w,x,E,LO,theta,delta;
string filename;
char *outputfilename = "output.txt";
ifstream inFile;
ofstream outputfile(outputfilename);
cout << "Please enter the name of the file you wish to open: ";
cin >> filename;
inFile.open(filename.c_str());
if (inFile.fail())
{
cout << "\nThe file named " << filename
<< " was not successfully opened"
<< "\n Please check that the file currently exists."
<<endl;
system("PAUSE");
exit(1);
}
cout << "\nThe file has been successfully opened for reading.\n";
if (!outputfile){
cout << "Error Opening Output File: " << outputfilename
<< " .\nCheck if file already exists. "<< endl;
return 0 ;
}
cout << "Output File Success fully Opened. " << endl;
inFile >> num;
inFile >> b1;
inFile >> b2;
inFile >> b3;
inFile >> d1;
inFile >> d2;
inFile >> d3;
inFile >> w;
inFile >> E;
inFile >> LO;
cout << "b1 from file: " << b1<<endl;
cout << "b2 from file: " <<b2<<endl;
cout <<"b3 from file: " <<b3<<endl;
cout <<"d1 from file: " <<d1<<endl;
cout <<"d2 from file: " <<d2<<endl;
cout <<"d3 from file: " <<d3<<endl;
cout <<"w from file: " <<w<<endl;
cout <<"E from file: " <<E<<endl;
cout <<"LO from file: " <<LO<<endl;
if (structure == 1)
{
c2= (((b1 * d1) * (d1 / 2)) + ((b2 * d2) * (d1 + (d2/2))) + ((b3 * d3) * (d1 + d2 + (d3/2)))) / ((b1 * d1) + (b2 * d2) + (b3 * d3));
cout << "c2: " << c2 << " m\n";
I1= ((b1 * (pow(d1,3))) / 12) + (b1 * d1) * (c2 - (d1 / 2)) * (c2 - (d1 / 2));
cout << "I1: " << I1 << " m\n";
I2= (((b2 * (pow(d2,3))) / 12) + ((b2 * d2) * ((d1 + (d2 / 2) - c2) * (d1 + (d2 / 2) - c2))));
cout << "I2: " << I2 << " m\n";
I3= ((b3 * (pow(d3,3))) / 12) + (b3 * d3) * (pow((d1 + d2 + (d3/2) - c2),2));
cout << "I3: " << I3 << " m\n";
cout << "Sum of I: " << I1 + I2 + I3 << " m\n";
for (double LO = 0.0; LO <= 1.0; LO+=0.1)
{
theta= (((w * x) / (6 * E * ((b1 * (d1 * d1 * d1)) / 12) + (b1 * d1) * (c2 - (d1 / 2)) * (c2 - (d1 / 2)) + ((b2 * (d2 * d2 * d2)) / 12) + (b2 * d2) * ((d1 + (d2 / 2) - c2) * (d1 + (d2 / 2) - c2)) +((b3 * (d3 * d3 * d3)) / 12) + b3 * d3 * ((d1 + d2 + (d3/2) - c2) * (d1 + d2 + (d3/2) - c2))))) * (((3 * (LO * LO)) - (3 * LO * x) + (x * x)));
cout << "theta(" << LO << "): " << theta << endl;
}
outputfile << "I1 from file: " <<I1<< "m\n";
system("PAUSE");
return 0;
}
else if (structure>1)
{
cout <<"You did not type a valid number." <<endl;
system("PAUSE");
return 0;
}
system ("PAUSE");
return 0;
}
|