write code in C++ or C, run/load and provide output
Here is the code:
#include <iostream>
#include<string.h>
using namespace std;
struct wl
{
string name;
char c;
int row;
int column;
};
class al
{
public:
wl w[11];
int cw = 0;
int ns[7][3] = {0};
int sm[3][3] = {0};
string nsk[7][3];
string smk[3][3];
void fillSmoking(string name,int
r,int c)
{
if(sm[r-8][c-1]==1)
{
//cout<<"\n Seat already taken"<<endl;
int x =
newSeatSM(name);
if(x==0)
waitlist(name,'S',r,c);
}
else
{
smk[r-8][c-1] =
name;
sm[r-1][c-1] =
1;
}
}
void fillNoSmoking(string name, int
r, int c)
{
if(ns[r-1][c-1]==1)
{
//cout<<"\n Seat already taken"<<endl;
int x =
newSeatNS(name);
if(x==0)
waitlist(name,'N',r,c);
}
else
{
nsk[r-1][c-1] =
name;
ns[r-1][c-1] =
1;
}
}
int newSeatNS(string name)
{
int i,j;
for(i=0;i<7;i++)
for(j=0;j<3;j++)
if(ns[i][j]==0)
{
nsk[i][j]
= name;
ns[i][j] =
1;
return
1;
}
if(i==7&&j==3)
return 0;
}
int newSeatSM(string name)
{
int i,j;
for(i=0;i<3;i++)
for(j=0;j<3;j++)
if(sm[i][j]==0)
{
smk[i][j]
= name;
sm[i][j] =
1;
return
1;
}
if(i==3&&j==3)
return 0;
}
void waitlist(string name, char c,
int row, int column)
{
w[cw].name =
name;
w[cw].c =
c;
w[cw].row =
row;
w[cw].column =
column;
cw++;
}
void displayWaitlist()
{
cout<<"\n************************************"<<endl;
cout<<"*\t\tWAITING LIST "<<endl;
cout<<"*"<<endl;
cout<<"*\tNAME\tSMOKIN
CHOICE\tROW\tCOLUMN"<<endl;
cout<<"*"<<endl;
cout<<"\n************************************"<<endl;
for(int
i=0;i<cw;i++)
{
cout<<i+1<<"\t"<<w[i].name<<"\t"<<w[i].c<<"\t"<<w[i].row<<"\t"<<w[i].column<<endl;
}
}
void displayNS()
{
cout<<"\n************************************"<<endl;
cout<<"*\t\tNO SMOKING SECTION ";
cout<<"\n************************************"<<endl;
for(int
i=0;i<7;i++)
{
for(int j=0;j<3;j++)
cout<<nsk[i][j]<<"\t";
cout<<endl;
}
}
void displaySM()
{
cout<<"\n************************************"<<endl;
cout<<"*\t\t SMOKING SECTION ";
cout<<"\n************************************"<<endl;
for(int
i=0;i<3;i++)
{
for(int j=0;j<3;j++)
cout<<smk[i][j]<<"\t";
cout<<endl;
}
}
};
for input:
int main()
{
al a;
a.fillNoSmoking("CAPONE AL",1,1);
a.fillNoSmoking("SDFFDSF",1,1);
a.displayNS();
retrun 0;
}
output:
for input:
a.fillNoSmoking("CAPONE AL",1,1);
a.fillNoSmoking("STEVESON E",2,1);
a.fillNoSmoking("RINEHART JIM",3,1);
a.fillNoSmoking("SDFFDSF",4,1);
a.fillNoSmoking("GRTGEFRE ",5,1);
a.fillNoSmoking("SBSBCCSDBF",6,1);
a.fillNoSmoking("SBFJHFFH ZFD",7,1);
a.fillNoSmoking("CAPONE AL",1,2);
a.fillNoSmoking("STEVESON E",2,2);
a.fillNoSmoking("RINEHART JIM",3,2);
a.fillNoSmoking("SDFFDSF",4,2);
a.fillNoSmoking("GRTGEFRE ",5,2);
a.fillNoSmoking("SBSBCCSDBF",6,2);
a.fillNoSmoking("SBFJHFFH GKJ",7,2);
a.fillNoSmoking("CAPONE AL",1,3);
a.fillNoSmoking("STEVESON E",2,3);
a.fillNoSmoking("RINEHART JIM",3,3);
a.fillNoSmoking("SDFFDSF VH",4,3);
a.fillNoSmoking("GRTGEFRE ",5,3);
a.fillNoSmoking("SBSBCCSDBF",6,3);
a.fillNoSmoking("SBFJHFFH",7,3);
a.fillSmoking("JACKSON MICHAEL",8,1);
a.fillSmoking("SMYTH SUSAN",9,1);
a.fillSmoking("ALLISON DENNIS",10,1);
a.fillSmoking("HUMPHREY H",8,2);
a.fillSmoking("KENDRICKS AL",9,2);
a.fillSmoking("GREENBLATT RICHARD",10,2);
a.fillSmoking("WINSTON SALEM",8,3);
a.fillSmoking("JOBS STEVEN",9,3);
a.fillSmoking("DAVIS BOB",10,3);
a.fillSmoking("WOODS BILL",8,3);
a.displayNS();
a.displaySM();
a.displayWaitlist();
output:
write code in C++ or C, run/load and provide output Fast Flight Airlines is looking for a programmer. They are considering your applicatiorn for employment. As a test of your ability, they want yo...