-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.CPP
323 lines (277 loc) · 7.09 KB
/
main.CPP
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
#include<graphics.h>
#include<conio.h>
#include<iostream.h>
#include<dos.h>
#include<ctype.h>
void oput(char &ch2, char ch1)
{ ch2++;
if(ch2>=ch1)
ch2=ch1;
}
void thankyou()
{ clrscr();
char a='A',m='A',e='A',y='A',w='A',g='A',l='A',s='A',h='A',u='A';
char t='A',o='A',d='A',n='A',j='A',r='A',p='A',v='A';
char i='A',k='A',c='A';
for(int j1=0;j1<26;j1++)
{ clrscr();
cout<<"\n\n\t\t\t\tTHANK YOU";
cout<<"\n\n\n\t\t\t";
cout<<"\t";
cout<<"\n\n\t\t\t\t"<<s<<a<<v<<y<<a<<" "<<s<<a<<c<<h<<i<<" "<<g<<u<<p<<t<<a;
delay(100);
oput(s,'S');
oput(a,'A');
oput(v,'V');
oput(y,'Y');
oput(a,'A');
oput(s,'S');
oput(a,'A');
oput(c,'C');
oput(h,'H');
oput(i,'I');
oput(g,'G');
oput(u,'U');
oput(p,'P');
oput(t,'T');
oput(a,'A');
}
delay(250);
cout<<"\n\n\n\n\t\t\t Press any Key To Navigate" ;
cout<<"\n\n\n\t\t\t away from this page ";
getch();
clrscr();
}
float r,d,D,kt,syp,smax,sn,m;
long double fos;
float ans[5];
int i=0;
char ch='y';
//Definition of alpha().
void alpha(char a)
{
cout<<a<<" ";
delay(120); //Delays for 200 milli-seconds.
}
//Definition of welcomescreen().
void welcomescreen()
{ clrscr();
cout<<"\n\n\n\n\n\n\n\n\n\t\t ";
alpha('S');
alpha('T');
alpha('R');
alpha('E');
alpha('S');
alpha('S');
alpha('E');
alpha('S');
cout<<" ";
alpha('A');
alpha('N');
alpha('D');
cout<<" ";
alpha('S');
alpha('T');
alpha('R');
alpha('A');
alpha('I');
alpha('N');
alpha('S');
cout<<"\n\t\t -------------------------------------";
cout<<"\n\n\t\t \"PROBLEM SOLVING USING C++\"";
delay(2000);
clrscr();
}
//Function to create the shapes that the user will select
int shape()
{
int choice;
int gd = DETECT, gm;
initgraph(&gd, &gm, "C:\\TC\\BGI");
cout<<"\t\t\t Choose The Type Of Section :";
cout<<"\n\n\n\n\t\t 1\t\t\t\t 2";
cout<<"\n\n\n\n\n\n\n\n\n\t\t 3\t\t\t 4";
cout<<"\n\n\n\n\n\n\n\n\n\t\t 5\t\t\t\t 6";
cout<<"\n\n\n\n\n\n\t\t\t Enter Your Choice : ";
//Figure 1 code begins
line(100, 120, 200, 120);
line(100, 20, 200, 20);
line(100, 20, 100, 120);
arc(230, 20, 180, 270, 30);
arc(230, 120, 90, 180, 30);
line(230, 90, 270, 90);
line(230, 50, 270, 50);
line(270, 50, 270, 90);
//Figure 2 code begins
line(360, 120, 420, 120);
line(360, 20, 420, 20);
line(360, 20, 360, 120);
arc(435, 20, 180, 0, 15);
arc(435, 120, 0, 180, 15);
line(450, 20, 510, 20);
line(450, 120, 510, 120);
line(510, 20, 510, 120);
//Figure 3 code begins
rectangle(100, 160, 270, 260);
circle(185, 210, 20);
//Figure 4 code Begins
line(360, 160, 420, 160);
line(360, 270, 420, 270);
line(420, 270, 420, 160);
arc(435, 160, 180, 0, 15);
arc(435, 270, 0, 180, 15);
line(450, 270, 510, 270);
line(450, 160, 510, 160);
line(450, 270, 450, 160);
arc(450, 215, 317.4896, 42.5104, 81.394);
arc(420, 215, 137.4896, 222.5104, 81.394);
//Figure 5 code Begins
arc(230, 310, 180, 270, 30);
arc(230, 420, 90, 180, 30);
line(100, 310, 200, 310);
line(100, 420, 200, 420);
line(200, 310, 200, 420);
arc(200, 365, 151.1893,208.8107,114.1271);
arc(200, 365, 340.347, 19.653, 74.330);
line(230, 340, 270, 340);
line(230, 390, 270, 390);
//Figure 6 code Begins
arc(360, 365, 339.8637, 20.1363, 159.7654);
arc(510, 365, 159.8637, 200.1363, 159.7654);
line(360, 310, 510, 310);
line(360, 420, 510, 420);
circle(435, 365, 20);
cin>>choice;
closegraph();
return choice;
}
void getdata()
{
clrscr();
cout<<"\n\t\t\t\t Please Enter Data :\n";
cout<<"\n \'r\' Value (mm) : ";
cin>>r;
cout<<"\n \'d\' Value (mm) : ";
cin>>d;
cout<<"\n \'D\' Value (mm) : ";
cin>>D;
cout<<"\n Factor Of Saftey : ";
cin>>fos;
cout<<"\n\n r/d Value is : "<<r/d;
cout<<"\n\n D/d Value is : "<<D/d;
cout<<"\n\n REFER Design Data Handbook Pg. 31 to Pg.38 for value of Kt...";
cout<<"\n\n Kt Value is : ";
cin>>kt;
cout<<"\n\nEnter The Value of BENDING MOMENT (in kN-mm) : ";
cin>>m;
sn=((1000*m*32*7)/(22*d*d*d));
smax=kt*sn;
ans[i]=smax;
i++;
cout<<"\n Nominal Stress : (Mx32)/(pixd^3) : "<<sn<<" Mpa";
cout<<"\n Maximum Stress : KtxNominal Stress : "<<smax<<" Mpa";
getch();
}
void finalans()
{
float max=ans[0];
for(int l=1; l<i; l++)
{
if(ans[l]>max) max=ans[l];
}
cout<<"\n\n\n\n\n\t\t\t Considering the HIGHER value...";
cout<<"\n\n\t\t\t MAXIMUM STRESS IS : "<<max<<" Mpa";
cout<<"\n\n\t\t\t Since Factor of Safety ="<<fos;
cout<<"\n\n\t\t\t Yield Stress = FOS x Max. Stress";
cout<<"\n\n\t\t\t = "<<fos<<" x "<<max;
cout<<"\n\n\t\t\t = "<<fos*max<<" Mpa";
cout<<"\n REFER Design Data Handbook Pg.427 to Pg.429 to select material.";
}
float mmax,su,mmin,smax1,smin1,sa,sm,ktf,sen;
char material;
void bmcalc()
{
cout<<"\n\nEnter Magnitude of Bending Moment : ";
cin>>m;
cout<<"\nThus, \t Mmax = +"<<m<<" kN-mm";
cout<<"\n \t Mmin = -"<<m<<" kN-mm";
d=28;
smax1=((1000*m*32*7)/(22*d*d*d));
smin1=smax1;
sa=(smax1+smin1)/2;
sm=(smax1-smin1)/2;
cout<<"\n\nMax. Stress = +"<<smax1;
cout<<"\nMin. Stress = -"<<smin1;
cout<<"\n\nAmplitude Stress = (Max - Min)/2 = "<<sa;
cout<<"\n\nMean Stress = (Max + Min)/2 = "<<sm;
cout<<"\n\nAssuming The Material To Be Highly Sensitive,\nWe consider q=1";
ktf=kt;
cout<<"\n\nKtf = q(Kt-1)+1 = "<<ktf;
cout<<"\nFor Endurance Stress :";
cout<<"\n 0.5 x Ultimate Stress\tFOR STEELS";
cout<<"\n 0.4 x Ultimate Stress\tFOR CAST IRON";
cout<<"\nEnter Ultimate Stress (Mpa) : ";
cin>>su;
cout<<"\nEnter Type Of Material : (S/I) : ";
cin>>material;
tolower(material);
if(material=='s')
{
sen=0.5*su;
}
else
{
sen=0.4*su;
}
cout<<"\n\n\t\t\t Using SODERBERGS EQUATION : ";
cout<<"\nA=1\tFor Reversed Bending Moment";
cout<<"\nB=0.85 For All Cases";
cout<<"\nC=0.80 Depending on the Material";
float var1=((kt*sa)/(0.68*sen));
fos=1/var1;
cout<<"\n\nThus, FACTOR OF SAFETY = "<<fos;
if(fos<2) cout<<"\nWhich is NOT suitable...";
else cout<<"\nWhich is Suitable...";
getch();
}
//Main function that drives the entire program. You may also increase the waiting time at multiple points in the program as per requirement
void main()
{
clrscr();
int flag=1;
welcomescreen();
while(ch=='y')
{
while(flag)
{
int choice=shape();
switch(choice)
{
case 4:
case 5: flag=0;
break;
default: cout<<"\n\n\n\n\t\t\t INVALID CHOICE. Try Again.";
getch();
break;
}
}
getdata();
cout<<"\n\nDo You Want To Enter Data For Another Section? (Y/N) : ";
cin>>ch;
tolower(ch);
if(ch=='y') flag=1;
}
finalans();
getch();
char b;
clrscr();
cout<<"\n Do you want to check if Bending Moment is Reversed? (Y/N) : ";
cin>>b;
tolower(b);
if(b=='y')
{
bmcalc();
}
thankyou();
getch();
}