-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrailway.cpp
279 lines (266 loc) · 7.12 KB
/
railway.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
#include<iostream>
#include<stdlib.h>
#include<time.h>
#include<fstream>
using namespace std;
int main()
{
system("color 3F");
int i,a,b,g,r,z;
long int q;
string k,j,h;
fstream file;
srand(time(0));
{
otp:
cout<<"\t"<<"\t"<<"\t"<<"******( WELCOME TO [SNB] ONLINE RAILWAY RESERVATION SYSTEM )******"<<"\t"<<"\t"<<"\t"<<endl;
}
for(i=0;i<g;i++)
{
cout<<"type YES to CONTINUE"<<"\n";
{
cin>>k;
if(k!="YES")
{
cout<<"invalid input"<<"\n";
}
else
{
break;
}
}
}
file.open("user.txt",ios::app);
{
cout<<" Please enter your valid 9 DIGITS mobile number"<<endl;
for(i=0;i<g;i++)
{
cin>>q;
if(q<100000000)
{
cout<<"INVALID MOBILE NUMBER PLEASE TRY AGAIN "<<endl;
}
else
{
file<<"\t"<<"\t"<<"\t"<<"******( WELCOME TO [SNB] ONLINE RAILWAY RESERVATION SYSTEM )******"<<"\t"<<"\t"<<"\t";
file<<"\nENTERED NUMBER BY THE USER = "<<q<<endl;
cout<<"we'll send a confirmation OTP at your number "<<endl;
g=rand();
cout<<"HERE'S YOUR OTP == "<<g<<endl;
break;
}
}
cout<<"TYPE the LOCATION to start from"<<"\n";
cout<<"1. CHANDIGARH"<<"\t"<<"2. GURUGRAM"<<"\t"<<"3. NEWDELHI"<<endl;
for(i=0;i<g;i++)
{
cin>>k;
if(k=="CHANDIGARH" || k=="GURUGRAM" || k=="NEWDELHI")
{
file<<"STARTING LOCATION = "<<k<<endl;
break;
}
else
{
cout<<"invalid action performed please try again"<<endl;
}
}
again:
cout<<"TYPE the LOCATION to go to"<<"\n";
cout<<"1. NEWDELHI"<<"\t"<<"2. GURUGRAM"<<"\t"<<"3. CHANDIGARH"<<endl;
for(i=0;i<g;i++)
{
cin>>j;
{
if(j==k)
{
cout<<"not possible"<<endl;
goto again;
}
}
if(j=="CHANDIGARH"||j=="GURUGRAM"||j=="NEWDELHI"&&j!=k)
{
file<<"END LOCATION = "<<j<<endl;
break;
}
else
{
cout<<"invalid action performed please try again"<<endl;
}
}
cout<<"select the TRAIN you prefer"<<"\n";
cout<<"1. Shatabdi express"<<"\n"<<"2. Rajdhani express"<<"\n";
cin>>b;
file<<"PREFERRED TRAIN = (1) SHATABDI || (2) RAJDHANI "<<"\n"<<b<<endl;
cout<<"\n";
switch(b)
{
case 1:
{
cout<<"select the DEPARTURE day"<<endl;
cout<<"1. TUESDAY "<<"\t"<<"2. THURSDAY"<<"\t"<<"3. SATURDAY"<<endl;
cin>>b;
file<<"DEPARTURE DAY = (1) TUESDAY || (2) THURSDAY || (3) SATURDAY "<<"\n"<<b<<endl;
cout<<"choose the selected options for timings"<<"\n";
cout<<"morning : "<<"(1) 6.30am"<<"\n"<<"evening : "<<"(2) 5.00pm"<<"\n";
cin>>r;
file<<"TIMING FOR TRAIN = (1) 6.30AM || (2) 5.00PM"<<"\n"<<r<<endl;
switch(r)
{
case 1 :
{
for(i=0;i<g;i++)
{
cout<<"are you sure you want to book SHATABDI EXPRESS at 6.30am?Type YES to CONFIRM"<<"\n";
cin>>h;
if (h=="YES")
{
cout<<"your inputs are recorded"<<" EXPECTED FAIR = $750"<<endl;
break;
}
else
{
cout<<"invalid input"<<endl;
}
}
break;
}
case 2 :
{
for(i=0;i<g;i++)
{
cout<<"are you sure you want to book SHATABDI EXPRESS at 5.00 pm?Type YES to CONFIRM"<<"\n";
cin>>h;
if (h=="YES")
{
cout<<"your inputs are recorded"<<" EXCECTED FAIR = $750"<<endl;
break;
}
else
{
cout<<"invalid input"<<endl;
}
}
break;
}
}
break;
}
case 2 :
{
cout<<"select the DEPARTURE day."<<endl;
cout<<"1. TUESDAY "<<"\t"<<"2. THURSDAY"<<"\t"<<"3. SATURDAY"<<endl;
cin>>b;
file<<"DEPARTURE DAY = (1) TUESDAY || (2) THURSDAY || (3) SATURDAY "<<"\n"<<b<<endl;
cout<<"choose the selected options for timings"<<"\n";
cout<<"morning : "<<"(1) 3.00am"<<"\n"<<"evening : "<<"(2) 10.10pm"<<"\n";
cin>>r;
file<<"TIMING FOR TRAIN = (1) 3.00AM || (2) 10.10PM "<<"\n"<<r<<endl;
switch(r)
{
case (1) :
{
for(i=0;i<g;i++)
{
cout<<"are you sure you want to book RAJDHANI EXPRESS at 3-00pm?Type YES to CONFIRM"<<"\n";
cin>>h;
if (h=="YES")
{
cout<<"your inputs are recorded"<<" EXPECTED FAIR = $900"<<endl;
break;
}
else
{
cout<<"invalid input"<<endl;
}
}
break;
}
case 2 :
{
for(i=0;i<g;i++)
{
cout<<"are you sure you want to book RAJDHANI EXPRESS at 10.10pm?Type YES to CONFIRM"<<"\n";
cin>>h;
if (h=="YES")
{
cout<<"your inputs are recorded"<<" EXPECTED FAIR = $900"<<endl;
break;
}
else
{
cout<<"invalid input"<<endl;
}
}
break;
}
}
break;
}
default :
{
cout<<"couldn't perform any action!!"<<"\n"<<"please refresh the page to start again";
}
}
cout<<"we have sent a confirmation OTP to the number provided above"<<endl;
cout<<"please enter the otp number to get your tickets"<<endl;
for(i=2;i>=0;i--)
{
cin>>a;
if (a==g)
{
file<<"OTP SENT = "<<g<<endl;
cout<<"VERIFYING"<<endl;
break;
}
else
{
cout<<" invalid input "<< i <<" attempts left "<<endl;
if(i==0)
{
cout<<"your registration has been CANCELLED"<<endl;
goto otp;
}
}
}
cout<<"CONGRATULATON !!! YOUR SEATS ARE BOOKED."<<endl;
cout<<"Do you want to reserve any other seat ??"<<endl;
cout<<"press YES to continue or NO to exit."<<endl;
{
for(i=0;i<g;i++)
{
cin>>k;
if(k=="YES")
{
cout<<"seats left on the train = 5"<<endl;
for(i=0;i<g;i++)
{
cout<<"How many seats you want to book??"<<endl;
cin>>z;
if(z<=5)
{
file<<"TOTAL SEATS BOOKED = "<<z<<" + 1 = "<<z+1<<" SEATS are booked";
cout<<z<<" TICKETS are generated "<<"THANKYOU,PLEASE VISIIT AGAIN"<<endl;
file.close();
break;
}
else
{
cout<<"Invalid input !! PLESSE TRY AGAIN!! "<<endl;
}
}
}
else if(k=="NO")
{
cout<<"THANKS FOR USING SNB ONLINE RESERVATION PROGRAM !! WE HOPE TO SEE YOU SOON AGAIN"<<endl;
}
else
{
cout<<"INVALID INPUT"<<endl;
}
cout<<"#######************************************************************########";
}
}
}
return 0;
}