Advertisement
jhnksr

midterms, case study g8

Oct 10th, 2023
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 12.04 KB | Source Code | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <string>
  4. #include <cctype>
  5. #include <windows.h>
  6.  
  7. // ALL DEFAULT ARGUMENT ARE BUGGED, IT EITHER LOOPS INFINITELY OR LOOPS RIGHT BACK FROM THE START NEED TO FIX
  8.  
  9. using namespace std;
  10.  
  11.  
  12.  
  13. int main()
  14. {
  15.  
  16.     char bclass, mpref, spref, memb, spreq, dof;
  17.     string conf, email, sbclass, date, sdate, smpref, sspref, smemb, sspreq, sdof;
  18.     // added s to chars means selected e.g sdate = selected date, for the ticket/s
  19.  
  20.     int clOffer, dateOffer, mealOffer, seatOffer, membOffer, specOffer, duraOffer, clCon;
  21.  
  22.     // values for offers (the ones with && offers)
  23.  
  24.     cout << "Welcome to SkySail Airlines!" << endl << endl << endl;
  25.  
  26.     while (true)
  27.     {
  28.         cout << "Do you want to book a ticket? (Yes/No): ";
  29.         cin >> conf;
  30.  
  31.         if (conf == "No" || conf == "N" || conf == "n" || conf == "no")
  32.         {
  33.             system("cls");
  34.  
  35.             cout << "We would love to fly with you soon!\n\n" << endl;
  36.             break;
  37.         }
  38.         else if (conf == "Yes" || conf == "Y" || conf == "y" || conf == "yes" || conf == "ye")
  39.  
  40.  
  41.             system("cls");
  42.         cout << "Loading options...\n\n";
  43.         Sleep(3000);
  44.  
  45.  
  46.         system("cls");
  47.         cout << "SkySail Airlines Reservation System" << endl << endl;
  48.  
  49.         cout << "Booking Class" << endl << endl;
  50.         cout << "1. [F]irst Class\n2. [B]usiness\n3. [P]remium Economy\n4. [E]conomy" << endl << endl;
  51.         cin >> bclass;
  52.         system("cls");
  53.  
  54.  
  55.         switch (bclass)
  56.         {
  57.         case '1':
  58.         case 'F':
  59.         case 'f':
  60.             sbclass = "First Class";
  61.             clOffer = 1;
  62.             break;
  63.  
  64.         case '2':
  65.         case 'B':
  66.         case 'b':
  67.             sbclass = "Business";
  68.             clOffer = 2;
  69.             break;
  70.  
  71.         case '3':
  72.         case 'P':
  73.         case 'p':
  74.             sbclass = "Premium Economy";
  75.             clOffer = 3;
  76.             break;
  77.  
  78.         case '4':
  79.         case 'E':
  80.         case 'e':
  81.             sbclass = "Economy";
  82.             clOffer = 4;
  83.             break;
  84.  
  85.         default:
  86.             cout << "Invalid selection. Please choose a valid option." << endl;
  87.             continue;
  88.             //error when input is not in the case selection
  89.         }
  90.  
  91.  
  92.         system("cls");
  93.  
  94.         cout << "SkySail Airlines Reservation System" << endl << endl;
  95.  
  96.         cout << "Enter the date of flight (MM/DD/YYYY): ";
  97.         getline(cin, date);
  98.         cin >> date;
  99.  
  100.         string monthStr = date.substr(0, 2);
  101.         int month;
  102.         month = stoi(monthStr);
  103.  
  104.         if (month >= 1 && month <= 4)
  105.         {
  106.             sdate = "Peak";
  107.             dateOffer = 1;
  108.             //cout << "Peak season: January to April" << endl;
  109.         }
  110.         else if (month >= 10 && month <= 12)
  111.         {
  112.             sdate = "Peak";
  113.             dateOffer = 1;
  114.             //cout << "Peak season: October to December" << endl;
  115.         }
  116.         else if (month >= 6 && month <= 9)
  117.         {
  118.             sdate = "Off-peak";
  119.             dateOffer = 0;
  120.             //cout << "Off-peak season: May to September" << endl;
  121.         }
  122.         else
  123.         {
  124.             cout << "Invalid month. Please enter a valid date in the format MM/DD/YYYY." << endl;
  125.             //code breaks user-input is character, need to fix
  126.         }
  127.  
  128.  
  129.  
  130.         system("cls");
  131.  
  132.         cout << "SkySail Airlines Reservation System" << endl << endl;
  133.         cout << "What type of meal set would you prefer?" << endl;
  134.         cout << "1. [N]on-vegetarian\n2. [Ve]getarian\n3. [V]egan\n4. [G]luten-free\n\n";
  135.         cin >> mpref;
  136.  
  137.         switch (mpref)
  138.         {
  139.         case '1':
  140.         case 'N':
  141.         case 'n':
  142.             smpref = "Non-vegetarian";
  143.             mealOffer = 1;
  144.             break;
  145.  
  146.         case '2':
  147.         case 'VE':
  148.         case 've':
  149.         case 'Ve':
  150.             smpref = "Vegetarian";
  151.             mealOffer = 2;
  152.             break;
  153.  
  154.         case '3':
  155.         case 'V':
  156.         case 'v':
  157.             smpref = "Vegan";
  158.             mealOffer = 3;
  159.             break;
  160.  
  161.         case '4':
  162.         case 'G':
  163.         case 'g':
  164.             smpref = "Gluten-free";
  165.             mealOffer = 4;
  166.             break;
  167.  
  168.         default:
  169.             cout << "Invalid selection. Please choose a valid option." << endl;
  170.  
  171.         }
  172.  
  173.  
  174.         system("cls");
  175.  
  176.         cout << "SkySail Airlines Reservation System" << endl << endl;
  177.         cout << "What seat position would you like? " << endl;
  178.         cout << "1. [A]isle\n2. [W]indow\n3. [M]iddle" << endl << endl;
  179.         cin >> spref;
  180.  
  181.         switch (spref)
  182.         {
  183.         case '1':
  184.         case 'A':
  185.         case 'a':
  186.             sspref = "Aisle";
  187.             seatOffer = 1;
  188.             break;
  189.  
  190.         case '2':
  191.         case 'W':
  192.         case 'w':
  193.             sspref = "Window";
  194.             seatOffer = 2;
  195.             break;
  196.  
  197.         case '3':
  198.         case 'M':
  199.         case 'm':
  200.             sspref = "Middle";
  201.             seatOffer = 3;
  202.             break;
  203.  
  204.         default:
  205.             cout << "Invalid selection. Please choose a valid option." << endl;
  206.  
  207.         }
  208.  
  209.  
  210.         system("cls");
  211.  
  212.         cout << "SkySail Airlines Reservation System" << endl << endl;
  213.         cout << "Special Requirements" << endl;
  214.         cout << "1. [W]heelchair Access\n2. Near [R]estroom\n3. Extra [L]egroom\n4. [N]o Special Requirements\n" << endl;
  215.         cin >> spreq;
  216.  
  217.         switch (spreq)
  218.         {
  219.         case '1':
  220.         case 'W':
  221.         case 'w':
  222.             sspreq = "Wheelchair Access";
  223.             specOffer = 1;
  224.             break;
  225.  
  226.         case '2':
  227.         case 'R':
  228.         case 'r':
  229.             sspreq = "Near Restroom";
  230.             specOffer = 2;
  231.             break;
  232.  
  233.         case '3':
  234.         case 'L':
  235.         case 'l':
  236.             sspreq = "Extra Legroom";
  237.             specOffer = 3;
  238.             break;
  239.  
  240.         case '4':
  241.         case 'N':
  242.         case 'n':
  243.             sspreq = "No Special Requirements";
  244.             specOffer = 4;
  245.             break;
  246.  
  247.         default:
  248.             cout << "Invalid selection. Please choose a valid option." << endl;
  249.             break;
  250.         }
  251.  
  252.  
  253.         system("cls");
  254.         cout << "SkySail Airlines Reservation System" << endl << endl;
  255.         cout << "How long would you want to travel?" << endl;
  256.         cout << "1. [S]hort-haul\n2. [M]edium-haul\n3. [L]ong-haul\n\n";
  257.         cin >> dof;
  258.  
  259.         switch (dof)
  260.         {
  261.         case '1':
  262.         case 'S':
  263.         case 's':
  264.             sdof = "Short-haul";
  265.             duraOffer = 1;
  266.             break;
  267.  
  268.         case '2':
  269.         case 'M':
  270.         case 'm':
  271.             sdof = "Medium-haul";
  272.             duraOffer = 2;
  273.             break;
  274.  
  275.         case '3':
  276.         case 'L':
  277.         case 'l':
  278.             sdof = "Long-haul";
  279.             duraOffer = 3;
  280.             break;
  281.  
  282.         default:
  283.             cout << "Invalid selection. Please choose a valid option." << endl;
  284.             break;
  285.         }
  286.  
  287.  
  288.         system("cls");
  289.  
  290.         cout << "SkySail Airlines Reservation System" << endl << endl;
  291.         cout << "Loyalty Membership" << endl;
  292.         cout << "1. [G]old\n2. [S]ilver\n3. [B]ronze\n4. [N]one\n" << endl;
  293.         cin >> memb;
  294.  
  295.         switch (memb)
  296.         {
  297.         case '1':
  298.         case 'G':
  299.         case 'g':
  300.             smemb = "Gold";
  301.             membOffer = 1;
  302.             break;
  303.  
  304.         case '2':
  305.         case 'S':
  306.         case 's':
  307.             smemb = "Silver";
  308.             membOffer = 2;
  309.             break;
  310.  
  311.         case '3':
  312.         case 'B':
  313.         case 'b':
  314.             smemb = "Bronze";
  315.             membOffer = 3;
  316.             break;
  317.  
  318.         case '4':
  319.         case 'N':
  320.         case 'n':
  321.             smemb = "Unavailable";
  322.             membOffer = 4;
  323.             break;
  324.  
  325.         default:
  326.             cout << "Invalid selection. Please choose a valid option." << endl;
  327.             break;
  328.         }
  329.  
  330.         system("cls");
  331.         cout << "Fetching your selected details...\n\n\n\n";
  332.         Sleep(4000);
  333.  
  334.         system("cls");
  335.  
  336.         cout << "SkySail Airlines Reservation System" << endl << endl;
  337.         cout << "Selected seat class: " << sbclass << "\t\t" << "Flying on " << date << endl << endl;
  338.  
  339.         cout << "Preferred meal set: " << smpref << "\t\t" << "Seat preferrence: " << sspref << endl;
  340.         cout << "Duration of flight: " << sdof << "\t\t" << "Special Requirements: " << sspreq << endl << endl;
  341.         cout << smemb << " Membership" << endl << endl << endl;
  342.  
  343.         cout << "Due to your selected flight conditions, you have been granted with the following offers!" << endl << endl << endl;
  344.  
  345.  
  346.  
  347.         if (specOffer != 4)
  348.         {
  349.             cout << "\n\nDue to having " << sspreq << " requirement. We will provide you with ";
  350.  
  351.             if (specOffer == 1)
  352.             {
  353.                 cout << "ground staff assisstance during boarding and de-boarding and seats close to the entrance" << endl;
  354.             }
  355.             else if (specOffer == 2)
  356.             {
  357.                 cout << "seats near to the restroom" << endl;
  358.             }
  359.             else if (specOffer == 3)
  360.             {
  361.                 cout << "avail for front-row seats" << endl;
  362.             }
  363.            
  364.         }
  365.    
  366.         else
  367.            
  368.  
  369.  
  370.             // confirm food and then request email to send ticket
  371.            
  372.             break;
  373.        
  374.        
  375.             return 0;
  376.     }
  377. }
  378.  
  379.  
  380.  
  381.  
  382. /*
  383.         switch (clCon)
  384.         {
  385.         case (clOffer == 1 && membOffer == 1):
  386.  
  387.  
  388.  
  389.  
  390.         }
  391.  
  392.  
  393.             //Class conditions
  394.                 if (clOffer == 1 && membOffer == 1)
  395.                 {
  396.  
  397.  
  398.                 }
  399.                 else if (clOffer == 1)
  400.                 {
  401.  
  402.                 }
  403.                 else if (clOffer == 2 && membOffer == 1 || membOffer == 2)
  404.                 {
  405.  
  406.                 }
  407.                 else if (clOffer == 3 && dateOffer == 1)
  408.                 {
  409.  
  410.                 }
  411.                 else if (clOffer == 4 && seatOffer == 3)
  412.                 {
  413.  
  414.                 }
  415.                 else if (clOffer == 4 && membOffer == 3)
  416.                 {
  417.  
  418.                 }
  419.                 else
  420.  
  421.  
  422.                 //Duration offer
  423.                 if (duraOffer == 1 && seatOffer == 1)
  424.                 {
  425.                     cout << "Blanket and headphones" << endl;
  426.                     cout << "Free drink voucher" << endl;
  427.                 }
  428.                 else if (duraOffer == 1 && seatOffer == 2)
  429.                 {
  430.                     cout << "Blanket and headphones" << endl;
  431.                     cout << "Provided sleeping kit" << endl;
  432.                 }
  433.                 else if (duraOffer == 1)
  434.                 {
  435.                     cout << "Blanket and headphones" << endl;
  436.                 }
  437.                 else if (duraOffer == 2 && seatOffer == 2)
  438.                 {
  439.                     cout << "Entertainment system with charging port" << endl;
  440.                 }
  441.                 else if (duraOffer == 3 && mealOffer == 2 || mealOffer == 3)
  442.                 {
  443.                     cout << "Complimentary snack box" << endl;
  444.                 }
  445.                 else
  446.  
  447.                     cout << endl << endl << endl;
  448.     */
  449.  
  450.  
  451.  
  452.  
  453.  
  454. // clOffer, dateOffer, mealOffer, seatOffer, membOffer, specOffer, duraOffer;
  455.  
  456. /*
  457.     bclass, mpref, spref, memb, spreq, dof;
  458.  
  459.     conf, email, sbclass, date, sdate, smpref, sspref, smemb, sspreq, sdof;
  460.     // added s to chars means selected e.g sdate = selected date, for the ticket/s
  461.     // VALUES FOR MESSAGES
  462.  
  463.     clOffer, dateOffer, mealOffer, seatOffer, membOffer, specOffer, duraOffer;
  464.     // values for offers (the ones with && offers)
  465.  
  466. */
  467.  
  468.  
  469. /*
  470.  
  471. Conditions:
  472.  
  473. bclass(first class) = auto free wifi
  474. bclass(first class) && memb (gold) = airport lounge access
  475. bclass(economy) && spref(middle) = neck pillow
  476. bclass(business) && memb(silver||gold) = prio boarding
  477. bclass(premium economy) && dot(peak) = avail discount for next booking
  478. bclass(economy) && memb(bronze) = 5% discount on flight meal
  479.  
  480. dof(short-haul) && mpref(vegetarian||vegan) = offer snack box
  481. dof(medium-haul && spref(window) = es with charging port
  482. dof(long-haul) = blanket and headphones
  483. dof(long-haul) && spref(aisle)  = free drink voucher
  484. dof(long-haul) && spref(window)= sleeping kit
  485.  
  486.  
  487. mpref(vegan||gluten-free) = confirm meal 48 hours before flight
  488.  
  489. sreq(extra legroom) = always front-row seat
  490. sreq(wheelchair) = assistance, seat close to entrance
  491. sreq(near restroom) = not next to emergency exits
  492.  
  493.  
  494.  
  495.  
  496.  
  497.  
  498. */
  499.  
  500.  
  501. /*Conditions
  502. Booking Class: Economy, Premium Economy, Business, First Class.
  503. ● Date of Travel: Determines peak or off-peak travel times.
  504. ● Meal Preference: Vegetarian, Non-Vegetarian, Vegan, Gluten-Free, etc.
  505. ● Seat Preference: Aisle, Window, or Middle.
  506. ● Loyalty Membership: Gold, Silver, Bronze, or None.
  507. ● Special Requirements: Wheelchair access, near restroom, extra legroom.
  508. ● Duration of Flight: Short-haul (< 3 hours), Medium-haul (3-6 hours), Long-haul (>
  509. 6 hours).
  510. */
  511.  
  512.  
  513.  
  514. /*
  515.         //Class conditions
  516.         if (clOffer == 1 && membOffer == 1)
  517.         {
  518.             cout << "Free WiFi" << endl;
  519.             cout << "Airport Lounge Access" << endl;
  520.         }
  521.         else if (clOffer == 1)
  522.         {
  523.             cout << "Free WiFi" << endl;
  524.         }
  525.         else if (clOffer == 2 && membOffer == 1 || membOffer == 2)
  526.         {
  527.             cout << "Priority Boarding" << endl;
  528.         }
  529.         else if (clOffer == 3 && dateOffer == 1)
  530.         {
  531.             cout << "Your next flight booking is discounted" << endl;
  532.         }
  533.         else if (clOffer == 4 && seatOffer == 3)
  534.         {
  535.             cout << "Free Neck Pillow" << endl;
  536.         }
  537.         else if (clOffer == 4 && membOffer == 3)
  538.         {
  539.             cout << "5% discount of flight meals" << endl;
  540.         }
  541.         break;
  542.  
  543.         //Duration offer
  544.         if (duraOffer == 1 && seatOffer == 1)
  545.         {
  546.             cout << "Blanket and headphones" << endl;
  547.             cout << "Free drink voucher" << endl;
  548.         }
  549.         else if (duraOffer == 1 && seatOffer == 2)
  550.         {
  551.             cout << "Blanket and headphones" << endl;
  552.             cout << "Provided sleeping kit" << endl;
  553.         }
  554.         else if (duraOffer == 1)
  555.         {
  556.             cout << "Blanket and headphones" << endl;
  557.         }
  558.         else if (duraOffer == 2 && seatOffer == 2)
  559.         {
  560.             cout << "Entertainment system with charging port" << endl;
  561.         }
  562.         else if (duraOffer == 3 && mealOffer == 2 || mealOffer == 3)
  563.         {
  564.             cout << "Complimentary snack box" << endl;
  565.         }
  566.         break;
  567.         */
  568.  
  569.  
  570.  
  571.         /*
  572.         switch (membOffer)
  573.         {
  574.         case '1':
  575.             cout << "Free WiFi" << endl;
  576.  
  577.  
  578.         case '2':
  579.         cout << ""
  580.  
  581.         case '3':
  582.         case 'B':
  583.         case 'b':
  584.             smemb = "Bronze";
  585.             membOffer = 3;
  586.             break;
  587.  
  588.         case '4':
  589.         case 'N':
  590.         case 'n':
  591.             smemb = "Unavailable";
  592.             membOffer = 4;
  593.             break;
  594.         */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement