Hi guys (again), i am here with a new program! This time, i have created an airline reservation system that allows a user to choose a seat, the problem i having is, getting the program that this to remember that this seat has been booked, any tips on how to do this? here is the code:
#include<iostream>
usingnamespace std;
int main()
{
int choice,i,position;
bool firstclass[5] ={0};
bool secondclass[10] ={0};
char ch;
int seats[10]={0};
while(true)
{
cout<<"\t\tChoose your class\n";
cout<<"\t1.First Class\n";
cout<<"\t2.Second Class\t";
cin>>choice;
switch(choice)
{
case 1:
cout<<"Seats available \n";
for(i=1;i<=5;i++)
if (firstclass [firstclass] == 0)
{
cout <<i<<" ";
}
cout<<"\nChoose your seat (1-5)\n";
cin>>position;
break;
cout <<"\n Your seat number is:" << position << endl;
case 2:
cout<<"Seats available \n";
for(i=5;i<=10;i++)
{
cout<<i<<" ";
}
cout<<"\nChoose your seats (6-10)\n";
break;
}
cout<<"Wish to continue(Y/N)\n";
cin>>ch;
if(ch=='y' || ch=='Y') continue;
if(ch=='n' || ch=='N') exit(0);
}
return 0;
}
edit * Sorry, i think ive asked the question wrongly. What im asking for is for the program to remember that say for example, seat 5 is booked once it has already been booked.
This is just an assignment, im only a student i havent learnt vectors and that other stuff xD
you can use the file to save the details of the ticket book ..
then you can read the file and store it in the array or vector or map ( if you need to dispaly the complete details of the ticket )P
then you can check by iterating the array or vector or map .
if not booked then insert the details of the ticket into the file .
Sorry, i think ive asked the question wrongly. What im asking for is for the program to remember that say for example, seat 5 is booked once it has already been booked.
This is just an assignment, im only a student i havent learnt vectors and that other stuff xD