youo12

Code

Jun 4th, 2022 (edited)
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 5.49 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <conio.h>
  3. void main()
  4. {
  5.  
  6.     int age[10] = {0}, ticket_id[9] = {0}, status[9] = {0}, class, infant = 0, child = 0, adult = 0, s;
  7.     float class_mult, total_fare;
  8.     int person, trip, mult_trip, meal_opt, meal_p, choice;
  9.     char num, confirm, passport[9], name[9][28], email[28], dest_f[16], dest_t[16];
  10. main:
  11.     printf("\n       ********************************************************************\n");
  12.     printf("                        * Welcome to [name] airline system *                  \n");
  13.     printf("       ********************************************************************\n");
  14.     printf("Enter your choice from below\n");
  15.     printf(" 1 - Reservation\n 2 - Records \n 3 - Cancel \n 4 - Exit \n");
  16.     scanf("%d", &choice);
  17.     switch (choice)
  18.     {
  19.     case 1:
  20.         printf("Enter the number of travellers (Max : 9)\n");
  21.  
  22.         scanf("%d", &person);
  23.         getchar();
  24.         if (person <= 9)
  25.         {
  26.             printf("Seats are available!\n");
  27.         }
  28.         else
  29.         {
  30.             printf("No seats available!\n");
  31.             goto main;
  32.         }
  33.  
  34.         for (int i = 0; i < person; i++)
  35.         {
  36.             if (age[i] == 0)
  37.             {
  38.  
  39.                 printf("Enter the name of person %d\n", (i + 1));
  40.                 scanf("%s", &name[i]);
  41.                 getchar();
  42.                 printf("%s , Enter your passport number \n", name[i]);
  43.                 scanf("%s", &passport[i]);
  44.                 getchar();
  45.                 printf("%s ,Enter your age \n", name[i]);
  46.                 scanf("%d", &age[i]);
  47.                 getchar();
  48.             }
  49.         }
  50.         // for (int j = 0; j < person; j++)
  51.         // {
  52.         //     if (age[j]<=2)
  53.         //     {
  54.         //         infant++;
  55.         //     }
  56.         //     else if (age[j]<=12 && age[j]>2)
  57.         //     {
  58.         //         child++;
  59.         //     }
  60.         //     else adult++;
  61.  
  62.         // }
  63.  
  64.         printf("Enter your Mobile Number: \n");
  65.         scanf("%s", &num);
  66.         getchar();
  67.         // printf("num = %llu",num);
  68.         printf("Enter your Email: \n");
  69.         scanf("%s", &email);
  70.         getchar();
  71.         printf("Enter your Destination\n");
  72.         printf("From: \n");
  73.         scanf("%s", &dest_f);
  74.         getchar();
  75.         printf("To: \n");
  76.         scanf("%s", &dest_t);
  77.         getchar();
  78.     cls:
  79.         printf("\n Class:\n 1) Business \n 2) Premium Economy \n3) Economy \n");
  80.         scanf("%d", &class);
  81.         getchar();
  82.         switch (class)
  83.         {
  84.         case 1:
  85.             class_mult = 1.20;
  86.             break;
  87.         case 2:
  88.             class_mult = 1.10;
  89.             break;
  90.         case 3:
  91.             class_mult = 1;
  92.             break;
  93.  
  94.         default:
  95.             printf("You've entered the wrong choice please try again!\n");
  96.             goto cls;
  97.             break;
  98.         }
  99.     trip:
  100.         printf("Choose: \n 1)One way \n 2) Round trip \n");
  101.         scanf("%d", &trip);
  102.         getchar();
  103.         switch (trip)
  104.         {
  105.         case 1:
  106.             mult_trip = 1;
  107.             break;
  108.         case 2:
  109.             mult_trip = 2;
  110.             break;
  111.         default:
  112.             printf("You've entered the wrong choice please try again!\n");
  113.             goto trip;
  114.             break;
  115.         }
  116.     meal:
  117.         printf("Choose the meal package\n 1)Regular \n 2) Deluxe \n");
  118.         scanf("%d", &meal_opt);
  119.         getchar();
  120.         switch (meal_opt)
  121.         {
  122.         case 1:
  123.             meal_p = 500;
  124.             break;
  125.         case 2:
  126.             meal_p = 1500;
  127.             break;
  128.         default:
  129.             printf("You've entered the wrong choice please try again!\n");
  130.             goto meal;
  131.             break;
  132.         }
  133.         total_fare = ((float)((3000 + meal_p) * person * mult_trip)) * class_mult;
  134.         printf("Your Total Fare for this Flight is %.2fRs \n", total_fare);
  135.         printf("Would you like to proceed? (Y/N)\n");
  136.         confirm = getchar();
  137.         switch (confirm)
  138.         {
  139.         case 'Y':
  140.         case 'y':
  141.             printf("Your flight has been  confirmed! \n Here are the Flight details\n");
  142.           // Program is exiting here!!! Please help
  143.             for (int j = 0; j < person; j++)
  144.             {
  145.                 printf("%d) Name  = %s \n Passport no. = %s \nAge = %d \nTicket ID =  %d \n", (j + 1), name[j], passport[j], age[j], (j + 1));
  146.                 if (class == 1)
  147.                 {
  148.                     printf("Class = Business\n");
  149.                 }
  150.                 else if (class == 2)
  151.                 {
  152.                     printf("Class = Premium Economy\n");
  153.                 }
  154.  
  155.                 else
  156.                 {
  157.                     printf("Class = Business\n");
  158.                 }
  159.  
  160.                 printf("Seat no. = A-%d \n", (j + 1));
  161.             }
  162.             printf("\n From: %s \n To: %s \n");
  163.  
  164.             break;
  165.         case 'N':
  166.         case 'n':
  167.             printf("\nWe are redirecting you to the main menu.......\n ");
  168.             goto main;
  169.             break;
  170.         default:
  171.             break;
  172.         }
  173.         break;
  174.     case 2:
  175.  
  176.         break;
  177.     default:
  178.         printf("You've entered the wrong choice please try again!\n");
  179.         goto main;
  180.         break;
  181.     }
  182.  
  183.     // for (int j = 0; j < person; j++)
  184.     // {
  185.     //     printf(" the name of person %s is %s \n", (j + 1), name[j]);
  186.  
  187.     //     printf(" the age of person %d is %d \n", (j + 1), age[j]);
  188.     // }
  189. }
Add Comment
Please, Sign In to add comment