Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <conio.h>
- void main()
- {
- int age[10] = {0}, ticket_id[9] = {0}, status[9] = {0}, class, infant = 0, child = 0, adult = 0, s;
- float class_mult, total_fare;
- int person, trip, mult_trip, meal_opt, meal_p, choice;
- char num, confirm, passport[9], name[9][28], email[28], dest_f[16], dest_t[16];
- main:
- printf("\n ********************************************************************\n");
- printf(" * Welcome to [name] airline system * \n");
- printf(" ********************************************************************\n");
- printf("Enter your choice from below\n");
- printf(" 1 - Reservation\n 2 - Records \n 3 - Cancel \n 4 - Exit \n");
- scanf("%d", &choice);
- switch (choice)
- {
- case 1:
- printf("Enter the number of travellers (Max : 9)\n");
- scanf("%d", &person);
- getchar();
- if (person <= 9)
- {
- printf("Seats are available!\n");
- }
- else
- {
- printf("No seats available!\n");
- goto main;
- }
- for (int i = 0; i < person; i++)
- {
- if (age[i] == 0)
- {
- printf("Enter the name of person %d\n", (i + 1));
- scanf("%s", &name[i]);
- getchar();
- printf("%s , Enter your passport number \n", name[i]);
- scanf("%s", &passport[i]);
- getchar();
- printf("%s ,Enter your age \n", name[i]);
- scanf("%d", &age[i]);
- getchar();
- }
- }
- // for (int j = 0; j < person; j++)
- // {
- // if (age[j]<=2)
- // {
- // infant++;
- // }
- // else if (age[j]<=12 && age[j]>2)
- // {
- // child++;
- // }
- // else adult++;
- // }
- printf("Enter your Mobile Number: \n");
- scanf("%s", &num);
- getchar();
- // printf("num = %llu",num);
- printf("Enter your Email: \n");
- scanf("%s", &email);
- getchar();
- printf("Enter your Destination\n");
- printf("From: \n");
- scanf("%s", &dest_f);
- getchar();
- printf("To: \n");
- scanf("%s", &dest_t);
- getchar();
- cls:
- printf("\n Class:\n 1) Business \n 2) Premium Economy \n3) Economy \n");
- scanf("%d", &class);
- getchar();
- switch (class)
- {
- case 1:
- class_mult = 1.20;
- break;
- case 2:
- class_mult = 1.10;
- break;
- case 3:
- class_mult = 1;
- break;
- default:
- printf("You've entered the wrong choice please try again!\n");
- goto cls;
- break;
- }
- trip:
- printf("Choose: \n 1)One way \n 2) Round trip \n");
- scanf("%d", &trip);
- getchar();
- switch (trip)
- {
- case 1:
- mult_trip = 1;
- break;
- case 2:
- mult_trip = 2;
- break;
- default:
- printf("You've entered the wrong choice please try again!\n");
- goto trip;
- break;
- }
- meal:
- printf("Choose the meal package\n 1)Regular \n 2) Deluxe \n");
- scanf("%d", &meal_opt);
- getchar();
- switch (meal_opt)
- {
- case 1:
- meal_p = 500;
- break;
- case 2:
- meal_p = 1500;
- break;
- default:
- printf("You've entered the wrong choice please try again!\n");
- goto meal;
- break;
- }
- total_fare = ((float)((3000 + meal_p) * person * mult_trip)) * class_mult;
- printf("Your Total Fare for this Flight is %.2fRs \n", total_fare);
- printf("Would you like to proceed? (Y/N)\n");
- confirm = getchar();
- switch (confirm)
- {
- case 'Y':
- case 'y':
- printf("Your flight has been confirmed! \n Here are the Flight details\n");
- // Program is exiting here!!! Please help
- for (int j = 0; j < person; j++)
- {
- printf("%d) Name = %s \n Passport no. = %s \nAge = %d \nTicket ID = %d \n", (j + 1), name[j], passport[j], age[j], (j + 1));
- if (class == 1)
- {
- printf("Class = Business\n");
- }
- else if (class == 2)
- {
- printf("Class = Premium Economy\n");
- }
- else
- {
- printf("Class = Business\n");
- }
- printf("Seat no. = A-%d \n", (j + 1));
- }
- printf("\n From: %s \n To: %s \n");
- break;
- case 'N':
- case 'n':
- printf("\nWe are redirecting you to the main menu.......\n ");
- goto main;
- break;
- default:
- break;
- }
- break;
- case 2:
- break;
- default:
- printf("You've entered the wrong choice please try again!\n");
- goto main;
- break;
- }
- // for (int j = 0; j < person; j++)
- // {
- // printf(" the name of person %s is %s \n", (j + 1), name[j]);
- // printf(" the age of person %d is %d \n", (j + 1), age[j]);
- // }
- }
Add Comment
Please, Sign In to add comment