0% found this document useful (0 votes)
84 views3 pages

the Number For Ther Select Seat Row //the Seat Number //the Number For The Selected Letter

This code implements a seat reservation system for an airplane. It defines a 2D character array to represent the seats on the plane. It prompts the user to enter a row number and seat letter to select a seat. It uses switch statements to convert these to row and column indexes to access the corresponding element in the 2D array. It marks the selected seat as 'X' and prints the updated seating chart. The user can then choose another seat for someone else or exit the program.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
84 views3 pages

the Number For Ther Select Seat Row //the Seat Number //the Number For The Selected Letter

This code implements a seat reservation system for an airplane. It defines a 2D character array to represent the seats on the plane. It prompts the user to enter a row number and seat letter to select a seat. It uses switch statements to convert these to row and column indexes to access the corresponding element in the 2D array. It marks the selected seat as 'X' and prints the updated seating chart. The user can then choose another seat for someone else or exit the program.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

#include "iostream"

char seat[7]
[5]={'1','A','B','C','D','2','A','B','C','D','3','A','B','C','D','4','A','B
','C','D','5','A','B','C','D','6','A','B','C','D','7','A','B','C','D'};
char option,seatAlp;
int i,j;
int ExitYesNo=1;
int Row;//the number for ther select seat row
int Column;//The seat number
int seatNum;//The number for the selected letter
void main()
{
std::cout<<"\nWelcome To Air-Asia.";
std::cout<<"\n--------------------------------------\n";
for (i=0; i<7; i++)
{
std::cout<<"\n";
for(j=0;j<=4;j++)
std::cout<<seat[i][j]<<"\t";
}
std::cout<<"\n--------------------------------------\n";
for ( ;ExitYesNo=1; )
{
std::cout<<"\nPLease Enter Your Desired Seat Location: ";
std::cin>>seatNum;
std::cin>>seatAlp;
//Gets the numer of the seat selected, 1,2,3,4,5,6, or 7
switch (seatNum)
{
case 1:
Row=0;
break;
case 2:
Row=1;
break;
case 3:
Row=2;
break;
case 4:
Row=3;
break;
case 5:
Row=4;
break;
case 6:
Row=5;
break;
case 7:

Row=6;
break;

default:
Row=8;
std::cout<<"\nInvalid Input";
break;

//Gets the character of the seat selected, A, B, C, or D


switch (seatAlp)
{
case 'a': case 'A':
Column=1;
break;
case 'b':case 'B':
Column=2;
break;
case 'c': case 'C':
Column=3;
break;

case 'd':case 'D':


Column=4;
break;

if (seat[Row][Column]=='X')
std::cout<<"\nWe Are Sorry To Inform You That Your
Desired Seat Location Is No More Avialable\n";
seat[Row][Column]='X';
std::cout<<"\nThank You For Flying Air-Asia : \n";
for (i=0;i<7;i++)
{
std::cout<<"\n";
for(j=0;j<=4;j++)
std::cout<<seat[i][j]<<"\t";
}
//Choose Another seat location for a friend or
family member

std::cout<<"\n--------------------------------------";
std::cout<<"\nDo You Wish To Choose Another Seat For A
Friend Or Family Member?\n";
std::cout<<"Enter -> 'Y' To Continue\n\t-> 'N' To Exit ";
std::cin>>option;
switch (option)
{
case 'y': case 'Y'://Proceed to choose another seat
ExitYesNo=1;
break;
case 'n': case 'N'://stop
ExitYesNo=0;

break;

default:
std::cout<<"Invalid Input"<<std::endl;
break;

std::cout<<"\n--------------------------------------";
}
system("PAUSE");
}

You might also like