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 109 110 111 112 113 114 115 116 117 118
|
#include <iostream>
#include <iomanip>
#include <cctype>
#include <string>
using namespace std;
void logo();
void initialize(int SCLASS[4][6], int ECO[6][8]);
void getdata(char &choice, char &row, int &col,char &row1, int &col1);
void Superior(int SCLASS[4][6],char row, int col);
void Economy(int ECO[6][8],char row1, int col1);
int main()
{
char row,row1;
int col,col1,SCLASS[4][6],ECO[6][8];
initialize(SCLASS,ECO);
getdata(row, col,row1,col1);
Superior(SCLASS,row,col);
Economy(ECO,row1,col1);
system("pause");
}
void initialize(int SCLASS[4][6],int ECO[6][8])
{
int a,b,c,d;
for(a=0;a<6;a++)
for(b=0;b<8;b++)
ECO[a][b]=0;
for(c=0;c<4;c++)
for(d=0;d<6;d++)
SCLASS[c][d]=0;
}
void getdata(char &row, int&col,char &row1, int&col1)
{
int SCLASS[4][6];
char choice;
cout<<"Please select your class SUPERIOR or ECONOMY: ";
cin>>choice;
switch(choice){
case 'S':
cout<<"Please select your seat(row): ";
cin>>row;
row = static_cast<char>(toupper(row));
cout<<"Please select your seat(col): ";
cin>>col;
break;
case 'E':
cout<<"Please select your seat(row): ";
cin>>row1;
row1 = static_cast<char>(toupper(row1));
cout<<"Please select your seat(col): ";
cin>>col1;
break;
default:
cout<<"Invalid choice please re-enter: ";
cin>>choice;
}
}
void Superior(int SCLASS[4][6],char row, int col){
SCLASS[static_cast<int>(row)-65] [col-1]=1;
char ascii='A';
cout<<right<<setw(10);
for(int num=1;num<7;num++)
cout<<right<<setw(6)<<"0"<<num;
cout<<endl;
cout<<" "<<"__________________________________________"<<endl;
for(int i=0;i<4;i++){
if((i+1)%3==0){
cout<<" "<<"| |"<<endl;
cout<<" | aisles |"<<endl;
cout<<" "<<"__________________________________________"<<endl;
}
cout<<left<<setw(3);
cout<<ascii++<<left<<setw(2)<<fixed<<"|";
for(int j=0;j<6;j++){
cout<<right<<SCLASS[i][j]<<left<<setw(6)<<" |"<<fixed;
}
cout<<endl;
cout<<" "<<"__________________________________________"<<endl; }
}
void Economy(int ECO[6][8],char row1,int col1){
ECO[static_cast<int>(row1)-65] [col1-1]=1;
char ascii='A';
cout<<right<<setw(10);
for(int num=1;num<9;num++)
cout<<right<<setw(6)<<"0"<<num;
cout<<endl;
cout<<" "<<"________________________________________________________"<<endl;
for(int i=0;i<6;i++){
if((i+1)%4==0){
cout<<" "<<"| |"<<endl;
cout<<" | aisles |"<<endl;
cout<<" "<<"________________________________________________________"<<endl;
}
cout<<left<<setw(3);
cout<<ascii++<<left<<setw(2)<<fixed<<"|";
for(int j=0;j<8;j++){
cout<<right<<ECO[i][j]<<left<<setw(6)<<" |"<<fixed;
}
cout<<endl;
cout<<" "<<"________________________________________________________"<<endl; }
}
|