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
|
//my project
#include "stdafx.h"
#include <iostream>
using namespace std;
void display(int r[],int set_value,char plane)
{
int i;
for (i=0;i < set_value; i++)
cout<<r[i];
cout<<"\n";
}
void booking(int a[],int set_value,char plane)
{
int seat_no;
cout<<"\nChoose where you would like to sit (seats 0 to 7) ";
cin>>seat_no;
if (a[seat_no]<1)
{
a[seat_no]=seat_no;
a[seat_no]=1;
cout<<" \nSeat number "<<seat_no<<" is now booked.\n";
}
else
cout<<"\nSeat "<<seat_no<<" is already booked\n";
}
void setup(int a[],int b[],int set_value)
{
for (int j = 0; j < set_value; j++)
a[j] = 0;
for (int i = 0;i < set_value; i++)
b[i] = 0;
}
void menu(int a[],int b[],int set_value)
{
int choice ;
char plane;
do
{
cout<<"\n1.\tMake a booking\n\n";
cout<<"2.\tDisplay booking\n\n";
cout<<"3.\tExit\n";
cout<<"\nEnter choice: \n";
cin>>choice;
if (choice == 1)
{
cout<<"Pick your flight[a or b] ";
cin>>plane;
if (plane=='a')
booking(a,set_value,plane);
else
if (plane =='b')
booking(b,set_value,plane);
}
if (choice == 2)
{
cout<<"Pick your flight[a or b] ";
cin>>plane;
if (plane =='a')
display(a,set_value,plane);
else
if (plane =='b')
display(b,set_value,plane);
}
}
while (choice <3);
cout << "\n";
}
void main()
{
const int t=8;
int b[t];
int c[t];
setup(b,c,t);
menu(b,c,t);
cout<<"\n\nThank you for using the program.\n";
system("pause");
}
|