-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflight.cpp
337 lines (300 loc) · 10.7 KB
/
flight.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
324
325
326
327
328
329
330
331
332
333
334
335
336
337
#include<iostream>
#include<fstream>
#include<iomanip>
#include<string.h>
using namespace std;
void mainMenu();
class Management{
public:
Management(){
mainMenu();
}
};
class detail{
public:
static string name,gender;
int phoneno;
int age;
string add;
static int cid;
char arr[100];
void information(){
cout<<"Enter coustomer id : \n";
cin>>cid;
cout<<"Enter name : \n";
cin>>name;
cout<<"Enter your Age : \n";
cin>>age;
cout<<"Enter your gender : \n";
cin>>gender;
cout<<"Enter your address : \n";
cin>>add;
cout<<"enter your phone number : \n";
cin>>phoneno;
cout<<"\n ";
cout<<"Your details is saved with us [-_-] \n";
}
};
int detail::cid;
string detail::name;
string detail::gender;
class registeration{
public:
static int choice;
int choice1;
int back;
static float charges;
void flight(){
string flightn[]={"Dubai ","Canada ","USA "};
for(int i=0;i<3;i++){
cout<<(i+1)<<".flight to "<<flightn[i]<<endl;
}
cout<<"\t\t---Welcome to Asim airlines--- \n\n";
cout<<"Press the number of country which you want to book the flight : \n";
cin>>choice;
switch(choice){
case 1:{
cout<<"\n|Welcome to Dubai emirates|\n";
cout<<"Your comfort is our priority,Enjoy the journey\n";
cout<<"\nFollowing are the flights\n";
cout<<"1.DUB -498"<<endl;
cout<<"08-01-2023 8:00AM 10hrs Rs.14000"<<endl;
cout<<"2.DUB -658"<<endl;
cout<<"09-01-2023 1:00PM 11hrs Rs.10000"<<endl;
cout<<"3.DUB -564"<<endl;
cout<<"10-01-2023 6:00PM 9hrs Rs.9000"<<endl;
cout<<"\t\nselect the flight you want to book :";
cin>>choice1;
if(choice1==1){
charges=14000;
cout<<"\nYou haved successfuly bookes the flight DUB-498"<<endl;
cout<<"YOu can go back to menu and take the ticket"<<endl;
}
else if(choice1==2){
charges=10000;
cout<<"\nYou haved successfuly bookes the flight DUB-658"<<endl;
cout<<"YOu can go back to menu and take the ticket"<<endl;
}
else if(choice1==3){
charges=9000;
cout<<"\nYou haved successfuly bookes the flight DUB-564"<<endl;
cout<<"YOu can go back to menu and take the ticket"<<endl;
}
else{
cout<<"\nInvlaid input ,shifting to the previous menu"<<endl;
flight();
}
cout<<"Press any key to go back to tha main menu:"<<endl;
cin>>back;
if(back==1){
mainMenu();
}
else{
mainMenu();
}
}
case 2:{
cout<<"\n|Welcome to Canadian Airlines| \n";
cout<<"Your comfort is our priority,Enjoy the journey\n";
cout<<"\nFollowing are the flights\n";
cout<<"1.CA -398"<<endl;
cout<<"08-01-2023 8:00AM 19hrs Rs.30000"<<endl;
cout<<"2.CA -258"<<endl;
cout<<"09-01-2023 1:00PM 17hrs Rs.24000"<<endl;
cout<<"3.CA -164"<<endl;
cout<<"10-01-2023 6:00PM 16hrs Rs.20000"<<endl;
cout<<"\t\nselect the flight you want to book :";
cin>>choice1;
if(choice1==1){
charges=30000;
cout<<"\nYou haved successfuly bookes the flight CA-398"<<endl;
cout<<"YOu can go back to menu and take the ticket"<<endl;
}
else if(choice1==2){
charges=24000;
cout<<"\nYou haved successfuly bookes the flight CA-258"<<endl;
cout<<"YOu can go back to menu and take the ticket"<<endl;
}
else if(choice1==3){
charges=20000;
cout<<"\nYou haved successfuly bookes the flight CA-164"<<endl;
cout<<"YOu can go back to menu and take the ticket"<<endl;
}
else{
cout<<"\nInvlaid input ,shifting to the previous menu"<<endl;
flight();
}
cout<<"Press any key to go back to tha main menu:"<<endl;
cin>>back;
if(back==1){
mainMenu();
}
else{
mainMenu();
}
}
case 3:{
cout<<"\n|Welcome to US Airways| \n";
cout<<"Your comfort is our priority,Enjoy the journey\n\n";
cout<<"\nFollowing are the flights\n\n:";
cout<<"1.US -698"<<endl;
cout<<"08-01-2023 8:00AM 19hrs Rs.45000"<<endl;
cout<<"2.US -758"<<endl;
cout<<"09-01-2023 1:00PM 17hrs Rs.40000"<<endl;
cout<<"3.US -864"<<endl;
cout<<"10-01-2023 6:00PM 16hrs Rs.35000"<<endl;
cout<<"\t\nselect the flight you want to book :";
cin>>choice1;
if(choice1==1){
charges=45000;
cout<<"\nYou haved successfuly bookes the flight US-698"<<endl;
cout<<"YOu can go back to menu and take the ticket"<<endl;
}
else if(choice1==2){
charges=40000;
cout<<"\nYou haved successfuly bookes the flight US-758"<<endl;
cout<<"YOu can go back to menu and take the ticket"<<endl;
}
else if(choice1==3){
charges=35000;
cout<<"\nYou haved successfuly bookes the flight US-864"<<endl;
cout<<"YOu can go back to menu and take the ticket"<<endl;
}
else{
cout<<"Invlaid input ,shifting to the previous menu"<<endl;
flight();
}
cout<<"\nPress any key to go back to tha main menu:"<<endl;
cin>>back;
if(back==1){
mainMenu();
}
else{
mainMenu();
}
}
default:{
cout<<"Invlaid input ,shifting to the previous menu"<<endl;
flight();
break;
}
}
}
};
float registeration::charges;
int registeration::choice;
class ticket : public registeration,detail{
public:
void bill(){
string destination="";
ofstream outf("datarecords.txt",ios::app);
{
outf<<"\t______Asim Airlines______\n";
outf<<"\\nt Ticket \n";
outf<<" \n";
outf<<"Customer ID :"<<detail::cid<<endl;
outf<<"Customer Name : "<<detail::name<<endl;
outf<<"Customer Gender : "<<detail::gender<<endl;
outf<<"\tDescription :\n";
if(registeration::choice==1){
destination="Dubai ";
}
else if(registeration::choice==2){
destination="Canada ";
}
else if(registeration::choice==3){
destination="USA ";
}
outf<<"\tDestination\t"<<destination<<endl;
outf<<"\tFlight cost :\t"<<registeration::charges<<endl;
}
outf.close();
}
void dispbill(){
ifstream ifs("datarecords.txt");
{
if(!ifs){
cout<<"File error\n";
}
while(!ifs.eof()){
ifs.getline(arr,100);
cout<<arr<<endl;
}
}
}
};
void mainMenu(){
int lchoice;
int schoice;
int back;
cout<<"\t_______Asim Airlines________\n";
cout<<"\t\t \n";
cout<<"\t Main Menu \n";
cout<<"\t\t "<<endl;
cout<<"\t press 1 to add the customer details "<<endl;
cout<<"\t press 2 for flight registeration "<<endl;
cout<<"\t press 3 for ticket and charges "<<endl;
cout<<"\t press 4 for exit "<<endl;
cout<<"\t "<<endl;
cout<<" \nEnter your choice "<<endl;
cin>>lchoice;
detail d;
registeration r;
ticket t;
switch(lchoice){
case 1:{
cout<<"\tCustomer "<<endl;
d.information();
cout<<"\npress any key toh go back to main menu \n";
cin>>back;
if(back==1){
mainMenu();
}
else{
mainMenu();
}
break;
}
case 2:{
cout<<"book a flight using a system \n";
r.flight();
break;
}
case 3:{
cout<<"Get your ticket \n";
t.bill();
cout<<"your ticket is printed,you can collect it \n";
cout<<"press 1 to display your ticket: \n";
cin>>back;
if(back==1){
t.dispbill();
cout<<"press any key to go to back menu \n";
cin>>back;
if(back==1){
mainMenu();
}
else{
mainMenu();
}
}
else{
mainMenu();
}
break;
}
case 4:{
cout<<"\t [Thank you] \n";
break;
}
default:{
cout<<"invalid input try agian";
mainMenu();
break;
}
}
}
int main(){
system("cls");
Management mobj;
return 0;
}