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 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
|
// SIMPLE BEAM
#include <iostream>
#include <fstream>
#include <cstdio>
#include <string>
#include <cmath> // note we need to include this to use pow(b,e)
#include <iomanip> // this has to be included to use setprecision()
#include <vector> // to handle variable-length arrays.
#include <sstream> // for I/O as string
#include <windows.h>
using namespace std;
/* Keeps window open upon completion. User closes
window by pressing key at the prompt. */
inline void keep_window_open()
{
char ch;
cin >> ch;
}
// Set console window size (Windows Only!)
void SetWindow(int Width, int Height)
{
_COORD coord;
coord.X = Width;
coord.Y = Height;
_SMALL_RECT Rect;
Rect.Top = 0;
Rect.Left = 0;
Rect.Bottom = Height - 1;
Rect.Right = Width - 1;
HANDLE Handle = GetStdHandle(STD_OUTPUT_HANDLE); // Get Handle
SetConsoleScreenBufferSize(Handle, coord); // Set Buffer Size
SetConsoleWindowInfo(Handle, TRUE, &Rect); // Set Window Size
}
// DECLARE GLOBAL VARIABLES
double L, rl, rr, ra, rb;
int j, k, nl, ns;
double vk, mk, mm, sm, z, z1, z2,wl;
double s, t;
double b, d, ec, i2;
string ldType;
string a1, a2, a3, a4, a5, a6;
//------------------------------------------------------------------------
// Set cursor position on the screen
void gotoxy(int x, int y)
{
HANDLE hConsoleOutput;
COORD dwCursorPosition;
dwCursorPosition.X = x;
dwCursorPosition.Y = y;
hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hConsoleOutput,dwCursorPosition);
}
//---------------------------------------------------------------------
// Enter row of spaces at 0,24
void EnterRowOfSpaces()
{
gotoxy(0,24);
cout << string(80, ' ');
}
//----------------------------------------------------------------------
// Print a bar in prompt area at 0,23
void PrintBar()
{
gotoxy(0,23);
cout << string(80, ':');
}
//-----------------------------------------------------------------------
//Print a line of dashes at 0,14
void PrintLine()
{
gotoxy(0,14);
cout << string(80, '-');
}
//-----------------------------------------------------------------------
// Clear 6 rows in display area
void Clear6Rows()
{
gotoxy(0,15);
string sp(80, ' ');
cout << sp;
for (int i=0; i<5; ++i)
cout << '\n' << sp;
}
//------------------------------------------------------------------------
// integer
void get_number(const string & prompt, int & value)
{
gotoxy(0,24);
EnterRowOfSpaces();
gotoxy(0,24);
cout << prompt;
cin >> value;
cin.ignore(1000, '\n');
}
//------------------------------------------------------------------------
// double
void get_number(const string & prompt, double & value)
{
gotoxy(0,24);
EnterRowOfSpaces();
gotoxy(0,24);
cout << prompt;
cin >> value;
cin.ignore(1000, '\n');
}
//------------------------------------------------------------------------
void get_string(const string & prompt, string & value)
{
gotoxy(0,24);
EnterRowOfSpaces();
gotoxy(0,24);
cout << prompt;
getline(cin, value);
}
//------------------------------------------------------------------------
//Enter the data function
void EnterData()
{
// TITLE
gotoxy(0,0);
cout << "\t\t\tSIMPLE BEAM DESIGN";
//int num1, num2, i;
PrintLine();
gotoxy(0,22);
cout << "ENTER DATA BELOW, WHEN PROMPTED:" << endl;
PrintBar();
// ENTER DATA REQUESTS IN PROMPT AREA
get_number("ENTER NUMBER OF SECTIONS TO BE CONSIDERED ALONG BEAM ", ns);
get_number("ENTER NUMBER OF LOADS ON THE SPAN: ", nl);
nl = nl + 1;
get_number("ENTER SPAN OF BEAM (metres): ", L);
// Display entered data at line 10
gotoxy(0,0);
cout << "No Of Sections: " << ns
<< " No of Loads: " << nl
<< " Span of Beam: " << L << " metres";
vector<int> tl( nl + 1 ); // variable-length array
//INITIALIZE ARRAYS FOR SF & BM AT SECTIONS
vector<double> vs( ns + 1 );
vector<double> ms( ns + 1 );
vector<double> W( nl + 1 );
vector<double> a( nl + 1 );
vector<double> c( nl + 1 );
vector<double> dist( ns );
vector<double> ds( ns );
double dk, zd, k1, mx;
double dm = 0, sd = 0;
vector<double> s1( ns + 1 );
vector<string> desc( nl + 1 );
// End of initialization of arrays
//---------------------------------------------------
// LOOP FOR NUMBER OF LOADS
//---------------------------------------------------
for (int j = 1; j<nl; j++)
{
ostringstream oss;
oss << "LOAD NUMBER " << j
<<": ENTER TYPE OF LOAD (1, 2, 3 or 4): ";
get_number(oss.str(), tl[j]);
get_string("ENTER DESCRIPTION OF LOAD: ", desc[j]);
get_number("ENTER LOAD, W (kN): ", W[j]);
get_number("ENTER DISTANCE OF START OF LOAD FROM LEFT SUPPORT (metres): ", a[j]);
get_number("ENTER LENGTH OF LOAD COVER - 0 IF PL (metres): ", c[j]);
cout << endl;
}
// End entering beam load and dimensional data
}
//-----------------------------------------------------------
int main()
{
// Set the console window size
SetWindow(80,30);
EnterData();
// Clear data entry areas
Clear6Rows();
gotoxy(0,24);
EnterRowOfSpaces();
gotoxy(0,24);
return 0;
}
|