-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLNTBCP2.CPP
354 lines (282 loc) · 7.64 KB
/
LNTBCP2.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
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
#include<ctype.h>
#include<string.h>
#include<process.h>
#include<stdio.h>
#include<iomanip.h>
//*********************************************
// HOTEL-THE ENGINEERING LEGEND
// IN ASSOCIATION WITH CA ASPIRANT
//**********************************************
class HOTEL
{ int i; //customer choice
struct custom_enter //CUSTOMER DETAILS
{ char name [20];
char address [100];
long IDNO ;
}customer1;
struct check_in //CHECK IN SERVICE
{ int roomno;
char roomtype;
char othserv;
int durofstay;
float roomcharge;
}checkinserv;
struct check_out //CHECK OUT SERVICE
{ long billno;
float totalbill ;
}checkoutserv;
struct restaurant //RESTAURANT SERVICE
{char foodtype;
int noofdishes;
float retbill;
}restserv;
struct bar //BAR SERVICE
{ char dtype;
float dbill;
}barserv;
struct swimpool //SWIMMING POOL SERVICE
{ int durofswim;
float swimcharge;
}poolserv;
public:
void welcome(); //ENTER THE DRAGON
void custom_details(); //ENTER YOUR DETAILS
void room_details(); //WHAT KIND OF ROOM YOU WANT?
void billup(); //HERE IS YOUR BILL
void custom_care(); //HOW CAN WE HELP?
void custom_record(); //RECORDS STORED OF CUSTOMER
void custom_display(); //DISPLAY YOUR DETAILS
void checking_out(); //CHECKING OUT AND BILLING
};
HOTEL h1;
ofstream ofile("hotel.dat",ios::binary);
void HOTEL::welcome()
{clrscr();
cout<<setw(47)<<"welcome to hotel"<<endl;
cout<<setw(50)<<"THE ENGINEERING LEGEND"<<endl;
cout<<"do you want our services?"<<endl;
cout<<"type 'Y' for yes and 'N' for no"<<endl;
char ch;
cin>>ch;
ch=toupper(ch);
if(ch!='Y'&& ch!='N')
{ cout<<"enter a valid choice";
cin>>ch;
}
do
{ cout<<"ENTER YOUR CHOICES"<<endl;
cout<<"1. CHECK IN"<<endl<<"2. HELP"<<endl<<"3. EXIT"<<endl;
cin>>i;
switch (i)
{ case 1:
custom_details();
custom_record();
break;
case 2:
custom_care();
break;
case 3:
exit(0);
break;
default:
cout<<"enter a valid choice";
cin>>i;
break;
}
}while(ch=='Y'||ch=='N');
}
void HOTEL::custom_details()
{clrscr();
cout<<"enter your required data"<<endl;
cout<<"ENTER YOUR NAME:";
gets(customer1.name);
cout<<"ENTER YOUR ADDRESS:";
gets(customer1.address);
cout<<"ENTER YOUR IDENTITY NUMBER:";
cin>>customer1.IDNO;
room_details();
}
void HOTEL::room_details()
{clrscr();
cout<<"what kind of room do you want??"<<endl;
cout<<" TYPE:"<<endl;
cout<<" 'D' for deluxe AC"<<endl;
cout<<" 'S' for deluxe non AC"<<endl;
cout<<" 'L' for luxury suite"<<endl;
cin>>checkinserv.roomtype;
checkinserv.roomtype=toupper(checkinserv.roomtype);
switch (checkinserv.roomtype)
{case 'D':
checkinserv.roomno=101;
break;
case 'S':
checkinserv.roomno=201;
break;
case 'L':
checkinserv.roomno=301;
break;
default:
cout<<"enter a valid choice";
cin>>checkinserv.roomtype;
}
cout<<"do you want any other services?"<<endl;
char ch1;
cout<<"type 'Y' for yes and 'N' for no"<<endl;
cin>>ch1;
ch1=toupper(ch1);
if(ch1=='Y')
{ cout<<"enter the service you want"<<endl;
cout<<"TYPE:"<<endl;
cout<<" 'R' for restaurant"<<endl;
cout<<" 'S' for swimming pool"<<endl;
cout<<" 'B' for bar"<<endl;
cin>>checkinserv.othserv;
checkinserv.othserv=toupper(checkinserv.othserv);
switch (checkinserv.othserv)
{ case 'R':
cout<<"enter the type of food"<<endl;
cout<<"'V' for veg and 'N' for non-veg"<<endl;
cin>>restserv.foodtype;
restserv.foodtype=toupper(restserv.foodtype);
cout<<"enter number of dishes"<<endl;
cin>>restserv.noofdishes;
poolserv.swimcharge=0;
barserv.dbill=0;
break;
case 'S':
cout<<"enter the duration of swim in hours"<<endl;
cin>>poolserv.durofswim;
restserv.retbill=0;
barserv.dbill=0;
break;
case 'B':
cout<<"enter the drink type"<<endl;
cout<<"'A'for alcoholic and 'B' for non-alcoholic"<<endl;
cin>>barserv.dtype;
barserv.dtype=toupper(barserv.dtype);
restserv.retbill=0;
poolserv.swimcharge=0;
break;
default:
cout<<"enter a valid choice"<<endl;
cin>>checkinserv.othserv;
}
}
else if(ch1=='N')
cout<<"no extra services added"<<endl;
else
{ cout<<"enter a valid choice"<<endl;
cin>>checkinserv.othserv;
}
cout<<"enter your duration of stay in number of days"<<endl;
cin>>checkinserv.durofstay;
cout<<"you are allotted the room ."<<checkinserv.roomtype<<endl;
cout<<"room number "<<checkinserv.roomno<<endl;
cout<<"for a period of "<<checkinserv.durofstay<<" days"<<endl;
for(long j=0;j<100000000;j++); //time delay
clrscr();
cout<<"do you want to check out??"<<endl;
cout<<"type 'Y' for yes and 'N' for no"<<endl;
char ch2;
cin>>ch2;
ch2=toupper(ch2);
if(ch2=='Y')
checking_out();
else if(ch2=='N')
custom_display();
else
cout<<"enter a valid choice"<<endl;
}
void HOTEL::billup()
{ clrscr();
switch(checkinserv.roomtype)
{ case 'D':
checkinserv.roomcharge=checkinserv.durofstay*800;
break;
case 'S':
checkinserv.roomcharge=checkinserv.durofstay*500;
break;
case 'L':
checkinserv.roomcharge=checkinserv.durofstay*1500;
break;
}
switch(restserv.foodtype)
{ case 'V':
restserv.retbill=restserv.noofdishes*500;
break;
case 'N':
restserv.retbill=restserv.noofdishes*750;
break;
default:
restserv.retbill=0;
}
switch(barserv.dtype)
{ case 'A':
barserv.dbill=3750;
break;
case 'B':
barserv.dbill=770;
break;
default:
barserv.dbill=0;
}
poolserv.swimcharge=poolserv.durofswim*500;
checkoutserv.billno=101234;
checkoutserv.totalbill= checkinserv.roomcharge+restserv.retbill+barserv.dbill+poolserv.swimcharge;
cout<<"THANK YOU FOR YOUR COMFORTABLE STAY AT THE HOTEL"<<endl;
cout<<"your bill is as follows ------"<<endl;
cout<<"BILL NUMBER: "<<checkoutserv.billno<<endl;
cout<<"CUSTOMER NAME: "<<customer1.name<<endl;
cout<<"TOTAL BILL: "<<checkoutserv.totalbill<<endl;
checkoutserv.billno++;
for(long k=0;k<100000000;k++); //time delay
clrscr();
}
void HOTEL::custom_care()
{clrscr();
cout<<"how can we help?";
exit(0);
}
void HOTEL::custom_record()
{ ofile.write((char*)&h1,sizeof(h1));
}
void HOTEL::custom_display()
{ clrscr();
cout<<"here are your details"<<endl;
cout<<"NAME: "<<customer1.name<<endl;
cout<<"ADDRESS: "<<customer1.address<<endl;
cout<<"IDENTITY NUMBER: "<<customer1.IDNO<<endl;
for(long l=0;l<100000000;l++);
clrscr();
}
void HOTEL::checking_out()
{ clrscr();
ifstream ifile("hotel.dat",ios::binary);
if(!ifile)
{ cout<<"cannot open file"<<endl;
return;
}
cout<<"time to check out"<<endl;
cout<<"enter your identity number"<<endl;
long id1;
cin>>id1;
int m=0;
while(!ifile.eof())
{ ifile.read((char*)&h1,sizeof(h1));
if(customer1.IDNO==id1)
{ billup();
m++;
}
}
if(m==0)
cout<<"not found"<<endl;
ifile.close();
}
void main()
{ clrscr();
h1.welcome();
ofile.close();
}