#include <iostream>
#include <conio.h>
using namespace std;
void showSeats (void);
char firstClass[2][6];
char busClass [5][6];
char ecoClass [6][6];
int main()
{
char seatType;
int seatNum;
char seatChar;
// make all the seats available
for(int i =0; i<6; i++)
{
for(int j =0;j<6;j++)
{
if(i<2)
firstClass[i][j]='*';
if(i<5)
busClass[i][j] = '*';
ecoClass [i][j] = '*';
}
}
showSeats();
while(true)
{
cout<<"Enter the Seat type you want: "<<endl;
cout<<" A\t->>\tFirst Class"<<endl;
cout<<" B\t->>\tBusiness Class" <<endl;
cout<<" C\t->>\tEconomy Class" <<endl;
cin>>seatType;
cout<<"Enter the Desired seat Number: ";
cin>>seatNum;
cin>>seatChar;
if (seatType == 'A')
{
int temp = seatChar;
firstClass[seatNum-1][temp-65]='X';
}
if (seatType == 'B')
{
int temp = seatChar;
busClass[seatNum-3][temp-65]='X';
}
if (seatType == 'C')
{
int temp = seatChar;
ecoClass[seatNum-8][temp-65]='X';
}
showSeats();
}
getch();
return 0;
}
void showSeats (void)
{
// show the seats plan
cout<<"\tA\tB\tC\tD\tE\tF\n"<<endl;
for( int i = 0; i < 2; i++)
{
cout<<"Row "<<i+1<<"\t";
for( int j =0; j < 6; j++)
cout<<firstClass[i][j]<<"\t";
cout<<"\n"<<endl;
}
for( int i = 0; i < 5; i++)
{
cout<<"Row "<<i+3<<"\t";
for( int j =0; j < 6; j++)
cout<<busClass[i][j]<<"\t";
cout<<"\n"<<endl;
}
for( int i = 0; i < 6; i++)
{
cout<<"Row "<<i+8<<"\t";
for( int j =0; j < 6; j++)
cout<<ecoClass[i][j]<<"\t";
cout<<"\n"<<endl;
}
}
jalal hashmi 0 Newbie Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.