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
|
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
int f=0,s=6,ans, mainmenu;
bool firstclass [5]= {};
bool secondclass [10]= {};
int fspace = 4;
int sspace = 6;
char check,con, position;
int main()
{
mainmenu:
cout <<"\t--Hello, welcome to SHARMA AIRLINE RESERVATION--" << endl;
cout <<"--Please select the following:" << endl;
cout <<"--[1] For a First-class seat" << endl;
cout <<"--[2] For a Second-class seat" << endl;
cout <<"--[3] Quit program.\n\n" << endl;
do
{
cout<<"\tWhich class would you like?" << endl;
cin>>ans;
{
if (ans == 1)
goto firstClass;
}
{
if (ans == 2)
goto secondClass;
}
//if (ans == 1 && f<=5)
if (ans ==1)
{
firstClass:
cout << "\t--Welcome to first class--" << endl;
position =20;
while(position < 0 || position > 5)
{
cout <<"\tplease choose a seat"<< endl;
cin >> position;
if(position > 5 || position << 0)
{
cout << "THe seating arrangesments is 1-5 "<< endl;
}
}
f = position - 1;
if (f<=5)
{
if (firstclass [f] == 0)
{
firstclass [f] = 1;
cout << "Your seat number is: " << position << endl;
}
else
{
cout << "This seat is already booked" << endl;
}
}
else if (f > fspace)
{
cout << "The seating arrangements for this class is 1-5, please pick again." << endl;
}
cout<<"\t--Would You Like To Continue? (y/n)--\n";
cin>>check;
{
if (check == 'n')
goto mainmenu;
}
}
else if (ans == 1 && f>5)
{
cout<< "\tUnfortunately, the First class is now full." << endl;
cout<<"\tDo you want a seat in the Second classs? (y/n)\n";
cin>>con;
if ((con == 'Y' || con =='y') && s<=10)
{
secondClass:
cout << "\t--Welcome to Second class--" << endl;
cout<<"\tPlease choose a seat from 6-10"<< endl;
cin >> position;
//for (s = 0; s <=sspace; s++)
s = position - 48;
if (s<10)
{
if (secondclass [s] == 0)
{
secondclass [s] = 1;
cout << "Your seat number is: " << position << endl;
}
else
{
cout << "This seat is already booked" << endl;
}
}
else if (s < sspace)
{
cout << "The seating arrangements for this class is 6-5, please pick again." << endl;
}
cout<<"\t--Would You Like To Continue? (y/n)--\n";
cin>>check;
}
else if ((con == 'Y' || con =='y') && s>10)
{
cout<<"Sorry,all seats are taken!!\n\n";
cout<<"The next flight leaves in 3 hours;)!\n";
return 0;
}
else if (con != 'y' || con != 'Y')
{
cout <<"The next flight leaves in 3 hours!\n";
return 0;
}
}
else if (ans == 2 && s>10)
{
cout<<"\t\tSorry, but the second class is now full!\n";
cout<<"\tWould you like a seat in first class?(y/n)\n";
cin>>con;
if ((con == 'Y' || con =='y') && f<=5)
{
goto firstClass;
}
if ((con == 'Y' || con =='y') && f>5)
{
cout<<"Soryy,all seats are taken!!\n\n";
cout<<"\tWould you like a seat in secondclass class?(y/n)\n";
cin >> con;
if ((con == 'Y' || con =='y') && s>=6)
{
goto secondClass;
}
cout<<"The next flight leaves in 3 hours!\n";
return 0;
}
else if (con != 'y' || con != 'Y')
{
cout<<"The next flight leaves in 3 hours!\n";
return 0;
}
}
else if (ans>3)
{
cout<<"Incorrect Input!!\n\n\n";
cout<<"\n";
cout<<"\n";
return main();
}
}
while (check == 'y' || check == 'Y');
return 0;
}
|