-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSeating-arrangment.cpp
More file actions
109 lines (99 loc) · 2.65 KB
/
Seating-arrangment.cpp
File metadata and controls
109 lines (99 loc) · 2.65 KB
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
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
int f=0,s=9, ans;
bool firstclass [5] = {0,0,0,0,0};
bool secondclass [5]= {};
int fspace = 5;
int positionint = 0 ;
int sspace= 8;
char check, con, position;
using namespace std;
//Function declarations
void first_class();
void second_class();
//Variable declarations
short int answer = 0;
char cont = 'y'; //So we do not quit immediately! The user can make this to n (no) later on.
int main()
{
if(cont == 'n' || cont == 'N') //If the user chooses not to continue after booking a seat, then we will quit.
{
cout << "\t Thankyou for booking with SHARMA AIRLINE reservationss" << endl;
return 0;
}
cout << "\t---Welcome to the SHARMA AIRLINE booking system---" << endl;
cout << "\t---Which class would you like?---" << endl;
cout << "\t---(1) For First-Class---" << endl;
cout << "\t---(2) For Economy-Class---" << endl;
cin >> answer;
if(answer == 1)
{
first_class(); //Function call.
}
else if(answer == 2)
{
second_class(); //Function call.
}
else
{
return 0; //Any other number quits.
}
}
void first_class()
{
cout<<"\tPlease choose a seat from 1-5"<< endl;
cin >> positionint;
f = positionint - 1;
if (positionint > 5)
{
cout << "The seating arrangements for this class is 1-5, please pick again." << endl;
}
if (positionint <=5)
{
if (firstclass [f] == 0)//seat is free
{
firstclass [f] = 1;
cout << "Your seat number is: " << positionint << endl;
}
else
{
cout << "This seat is already booked" << endl;
}
}
cout << "Would you like to book another seat (y/n)? " << endl;
cin >> cont;
if(cont == 'y' || cont == 'Y')
{
main();
}
}
void second_class()
{
cout << "\t--Welcome to Second class--" << endl;
cout<<"\tPlease choose a seat from 6-10"<< endl;
s = positionint - 1;
cin >> positionint;
if (positionint <= 5 || positionint >= 11 )
{
cout << "The seating arrangements for this class is 6-10, please pick again." << endl;
}
if (positionint >= 6)
{
if (secondclass [s] == 0)
{
secondclass [s] = 1;
cout << "Your seat number is: " << positionint << endl;
}
else
{
cout << "This seat is already booked" << endl;
}
}
cout << "Would you like to book another seat (y/n)? " << endl;
cin >> cont;
if(cont == 'y' || cont == 'Y')
{
main();
}
}