-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCSC415_MiniGroupProject.cpp
489 lines (379 loc) · 14 KB
/
CSC415_MiniGroupProject.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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
/*
Course Code: CSC415
Company Name: Arau Airline
Author: Muhammad Ammar, Muhammad Muaz, Nur Azmatun
Group: RCS2401A
Objective: Mini Group Project
*/
#include <iostream>
#include <string.h>
using namespace std;
// function prototype
void displayMenu ();
void displayMenu2 ();
void displayMealsSet();
void calculatePrice (int, int, int, float&);
void calculateTax (float, float&);
void calculateBag (int, float&, float);
void calcMealsSet(int, float&);
// main function
int main () {
displayMenu ();
displayMenu2 ();
displayMealsSet();
// declaration and initialisation
float price, totalPayment=0, bag, priceMeals, priceBag=0, priceTax, totalAll;
bool proceed;
char ic[13], name[50], contactNumber[12];
int destination, way, type, meals;
do {
//reset priceBag to 0
priceBag = 0;
// input
cout << "Please enter your name: ";
cin.get (name, 50);
cin.ignore(50, '\n');
cout << "Please enter your IC number (Without '-'): ";
cin.get (ic, 13);
cin.ignore(13, '\n');
cout << "Please enter your contact number (Without '-'): ";
cin.get (contactNumber, 12);
cin.ignore(12, '\n');
cout << "Please enter destination (1 - 7): ";
cin >> destination;
cout << "One Way or Two Way? (1 - One Way / 2 - Two Way): ";
cin >> way;
cout << "Economy Class or Business Class? (1 - Economy / 2 - Business ): ";
cin >> type;
cout << "Total baggage capacity (in KG): ";
cin >> bag;
cout << "Please choose meals set (1 - 4): ";
cin >> meals;
cout << endl;
// function call for calculation
calculatePrice (destination, way, type, price);
calculateBag (type, priceBag, bag);
calcMealsSet (meals,priceMeals);
calculateTax (price,priceTax);
// calculation total for 1 person
totalPayment = price + priceBag + priceMeals + priceTax;
// receipt - display back all input for 1 person
cout << "-------------------------------------------------------------------" << endl;
cout << " ARAU AIRLINE " << endl;
cout << " RECEIPT " << endl;
cout << "-------------------------------------------------------------------" << endl;
cout << " NAME | " << name << endl;
cout << " IC NO. | " << ic << endl;
cout << " CONTACT NO. | " << contactNumber << endl;
cout << "-------------------------------------------------------------------" << endl;
cout << " TICKET TYPE | " << type << endl;
cout << " WAY | " << way << endl;
cout << " TICKET PRICE | RM" << price << endl;
cout << "-------------------------------------------------------------------" << endl;
cout << " MEAL SET | SET " << meals << endl;
cout << " MEAL PRICE | RM" << priceMeals << endl;
cout << " BAGGAGE CAPACITY | " << bag << " KG " << endl;
cout << " BAGGAGE FEE | RM" << priceBag << endl;
cout << " TAX | RM" << priceTax << endl;
cout << "-------------------------------------------------------------------" << endl;
cout << " TOTAL PAYMENT | RM" << totalPayment << endl;
cout << "-------------------------------------------------------------------" << endl;
// calculation total for all person / customer / passenger
totalAll = totalAll + totalPayment;
// prompt to continue or not
cout << "\nDo you want to continue? (1 - yes / 0 - no): ";
cin >> proceed;
cin.ignore(13, '\n');
cout << endl;
} while (proceed == true);
// display total payment for all person / customer / passenger
cout << "-------------------------------------------------------------------" << endl;
cout << " ARAU AIRLINE " << endl;
cout << " FINAL RECEIPT " << endl;
cout << "-------------------------------------------------------------------" << endl;
cout << " TOTAL PAYMENT | RM" << totalAll << endl;
cout << "-------------------------------------------------------------------" << endl;
return 0;
}
// function definition - calculate meals
void calcMealsSet (int meals, float& priceMeals) {
if (meals == 1) {
priceMeals = 20;
}
else if (meals == 2) {
priceMeals = 20;
}
else if (meals == 3) {
priceMeals = 30;
}
else if (meals == 4) {
priceMeals = 10;
}
else {
priceMeals = 0;
}
}
//function definition - calculate tax and charges
void calculateTax (float price, float& priceTax) {
//add passenger service charge RM11 + add service tax 6%
priceTax = (price*0.06) + 11;
}
//function definition - calculate baggage charge
void calculateBag (int type, float& priceBag, float bag) {
float extra;
//for economy class limited to 7KG
if ((type == 1) && (bag > 7)) {
extra = bag - 7;
priceBag = extra * 10;
}
//for business class limited to 14KG
else if ((type == 2) && (bag > 14)) {
extra = bag - 14;
priceBag = extra * 10;
}
}
// function definition - calculate price
void calculatePrice (int destination, int way, int type, float& price){
if (destination == 1) { // Alor Setar
if (way == 1){ // One way
if (type == 1){ //Economy
price = 34;
}
else if (type == 2) { //Business
price = 48;
}
else { //Wrong input for flight class
cout << "Error. Please enter correct type of flight class." << endl;
}
}
else if (way == 2){ //Two Way
if (type == 1){ //Economy
price = 61;
}
else if (type == 2) { //Business
price = 86;
}
else { //Wrong input for flight class
cout << "Error. Please enter correct type of flight class." << endl;
}
}
else { //Wrong input for one way or two way trip
cout << "Error. Please enter correct trip type." << endl;
}
}
else if (destination == 2){ //Penang
if (way == 1){
if (type == 1){
price = 54;
}
else if (type == 2) {
price = 76;
}
else {
cout << "Error. Please enter correct type of flight class." << endl;
}
}
else if (way == 2){
if (type == 1){
price = 98;
}
else if (type == 2) {
price = 138;
}
else {
cout << "Error. Please enter correct type of flight class." << endl;
}
}
else {
cout << "Error. Please enter correct trip type." << endl;
}
}
else if (destination == 3) { //Terengganu
if (way == 1){
if (type == 1){
price = 74;
}
else if (type == 2) {
price = 104;
}
else {
cout << "Error. Please enter correct type of flight class." << endl;
}
}
else if (way == 2){
if (type == 1){
price = 133;
}
else if (type == 2) {
price = 186;
}
else {
cout << "Error. Please enter correct type of flight class." << endl;
}
}
else {
cout << "Error. Please enter correct trip type." << endl;
}
}
else if (destination == 4) { //Kota Bharu
if (way == 1){
if (type == 1){
price = 64;
}
else if (type == 2) {
price = 90;
}
else {
cout << "Error. Please enter correct type of flight class." << endl;
}
}
else if (way == 2){
if (type == 1){
price = 115;
}
else if (type == 2) {
price = 161;
}
else {
cout << "Error. Please enter correct type of flight class." << endl;
}
}
else {
cout << "Error. Please enter correct trip type." << endl;
}
}
else if (destination == 5) { // Langkawi
if (way == 1){
if (type == 1){
price = 84;
}
else if (type == 2) {
price = 118;
}
else {
cout << "Error. Please enter correct type of flight class." << endl;
}
}
else if (way == 2){
if (type == 1){
price = 136;
}
else if (type == 2) {
price = 151;
}
else {
cout << "Error. Please enter correct type of flight class." << endl;
}
}
else {
cout << "Error. Please enter correct trip type." << endl;
}
}
else if (destination == 6) { // Sandakan
if (way == 1) {
if (type == 1){
price = 134;
}
else if (type == 2) {
price = 188;
}
else {
cout << "Error. Please enter correct type of flight class." << endl;
}
}
else if (way == 2){
if (type == 1){
price = 241;
}
else if (type == 2) {
price = 337;
}
else {
cout << "Error. Please enter correct type of flight class." << endl;
}
}
else {
cout << "Error. Please enter correct trip type." << endl;
}
}
else if (destination == 7) { //Kuching
if (way == 1){
if (type == 1){
price = 164;
}
else if (type == 2) {
price = 230;
}
else {
cout << "Error. Please enter correct type of flight class." << endl;
}
}
else if (way == 2){
if (type == 1){
price = 414;
}
else if (type == 2) {
price = 580;
}
else {
cout << "Error. Please enter correct type of flight class." << endl;
}
}
else {
cout << "Error. Please enter correct trip type." << endl;
}
}
//wrong input for destination
else {
cout << "Error. Please enter correct destination." << endl;
}
}
// function definition - display menu (destination and ticket price)
void displayMenu (){
cout << "|-------------------------------------------------------------------|" << endl;
cout << "| ARAU AIRLINE |" << endl;
cout << "|-------------------------------------------------------------------|" << endl;
cout << "| DESTINATION | ONE WAY | TWO WAY |" << endl;
cout << "| FROM -------------------------------------------------|" << endl;
cout << "| KLIA | ECONOMY | BUSINESS | ECONOMY | BUSINESS |" << endl;
cout << "|-------------------------------------------------------------------|" << endl;
cout << "| 1 - ALOR SETAR | 34.00 | 48.00 | 61.00 | 86.00 |" << endl;
cout << "| 2 - PENANG | 54.00 | 76.00 | 98.00 | 138.00 |" << endl;
cout << "| 3 - TERENGGANU | 74.00 | 104.00 | 133.00 | 186.00 |" << endl;
cout << "| 4 - KOTA BHARU | 64.00 | 90.00 | 115.00 | 161.00 |" << endl;
cout << "| 5 - LANGKAWI | 84.00 | 118.00 | 136.00 | 151.00 |" << endl;
cout << "| 6 - SANDAKAN | 134.00 | 188.00 | 241.00 | 337.00 |" << endl;
cout << "| 7 - KUCHING | 164.00 | 230.00 | 414.00 | 580.00 |" << endl;
cout << "|-------------------------------------------------------------------|" << endl << endl;
}
// function definition - display menu (Additional Infomation)
void displayMenu2 (){
cout << "|-------------------------------------------------------------------|" << endl;
cout << "| Standard (Economy) Baggage Capacity = 7 KG |" << endl;
cout << "| Premium (Business) Baggage Capacity = 14 KG |" << endl;
cout << "| Additional Baggage Capacity = RM 10.00 / KG |" << endl;
cout << "|-------------------------------------------------------------------|" << endl;
cout << "| Airport Tax = RM 11.00 |" << endl;
cout << "|-------------------------------------------------------------------|" << endl;
cout << "| Service Tax & Insurance (Flight = 6% of the net ticket price |" << endl,
cout << "| Delay, Trip Cancellation, Lost, |" << endl;
cout << "| Damaged or Stolen Luggage) |" << endl;
cout << "|-------------------------------------------------------------------|" << endl << endl;
}
// function definition - display meals set
void displayMealsSet () {
cout << "|-------------------------------------------------------------------|" << endl;
cout << "| MEALS SET |" << endl;
cout << "|-------------------------------------------------------------------|" << endl;
cout << "| SET 1 | NASI LEMAK WITH BOILED EGG AND MINERAL WATER | RM20 |" << endl;
cout << "|-------------------------------------------------------------------|" << endl;
cout << "| SET 2 | TUNA SANDWICH AND TEH TARIK | RM20 |" << endl;
cout << "|-------------------------------------------------------------------|" << endl;
cout << "| SET 3 | CHICKEN RENDANG WITH WHITE RICE AND TEH O | RM30 |" << endl;
cout << "|-------------------------------------------------------------------|" << endl;
cout << "| SET 4 | CHICKEN MUSHROOM SOUP AND 100 PLUS | RM10 |" << endl;
cout << "|-------------------------------------------------------------------|" << endl;
cout << "| Input '0' if you're not interested in any set of meals. |" << endl;
cout << "|-------------------------------------------------------------------|" << endl;
cout << endl;
}