Help me !! Why my seat map can't show in the second time for the second customer ??

#include <iostream>
#include<iomanip>
#include<string>
using namespace std;

int main()
{
const int size=30;
int fc=10,bc=20;
int a,b,tfc=0,tbc=0,s[size]={0},total=0,row=0,seat=0;
char c,cc,Y,N;
string x;


do
{

cout<<"Enter the class of the ticket :"<<endl;
cout<<"1/F - First class"<<endl;
cout<<"2/B - Business class"<<endl;

do
{
getline(cin,x);

if( x== "1" || x== "F")
{
cout<<"There are "<<fc<<" first class seats available."<<endl;
cout<<"How many tickets would you like to purchase?"<<endl;
cin>>a;
fc= fc-a;
tfc= tfc+a;

if(a>10)
{
cout<<"Not enough seat.Check to see any other seat available in other class? (Y / N)"<<endl;
cin>>cc;
a=0;
tfc=0;
fc=10;
}

switch(cc)
{
case 'Y':
cout<<"There are "<<bc<<" business class seats available."<<endl;
cout<<"How many tickets would you like to purchase?"<<endl;
cin>>b;
bc= bc-b;
tbc= tbc+b;
break;
case'N':
cout<<"Thank you for choosing FAST Airlines :)"<<endl;
system("pause");
}
}


else if( x=="2" || x=="B")
{
cout<<"There are "<<bc<<" business class seats available."<<endl;
cout<<"How many tickets would you like to purchase?"<<endl;
cin>>b;
bc= bc-b;
tbc= tbc+b;


if(b>20)
{
cout<<"Not enough seat.Check to see any other seat available in other class?(Y / N) "<<endl;
cin>>cc;
b=0;
tbc=0;
bc=20;
}

switch(cc)
{
case'Y':
cout<<"There are "<<fc<<" first class seats available."<<endl;
cout<<"How many tickets would you like to purchase?"<<endl;
cin>>a;
fc= fc-a;
tfc= tfc+a;
break;

case'N':
cout<<"Thank you for choosing FAST Airlines :)"<<endl;
system("pause");
}
}

if(!(x== "1" || x== "F" || x=="2" || x=="B"))
{
cout<<"Invalid,choice,please try again !"<<endl;
cin.clear();
}
}while(!(x== "1" || x== "F" || x=="2" || x=="B"));

total= tfc + tbc;

cout<<"Number of tickets to be purchased :"<<endl;

if(x== "1"|| x== "F")
cout<<"First Class"<<setw(13)<<a<<endl;

else if (x== "2" || x== "B")
cout<<"Business class"<<setw(13)<<b<<endl;

else
cout<<"0"<<endl;


cout<<"Number of tickets left :"<<endl;
cout<<"First class"<<setw(13)<<fc<<endl;
cout<<"Business class"<<setw(10)<<bc<<endl;

do
{
cout<<"Select one of the following options."<<endl;
cout<<"0/X - Exit Program"<<endl;
cout<<"1/f - Plane Depart"<<endl;
cout<<"2/M - Show Seat Map"<<endl;
cout<<"Any Another key - Next Customer"<<endl;
cin>>c;
cout<<endl;

switch(c)
{
case '0': case 'X':
return 0;
break;

case '1': case 'f':
cout<<"Summary"<<endl;
cout<<"-------"<<endl;
cout<<"First class passenger"<<setw(13)<<tfc<<endl;
cout<<"Business class passengers"<<setw(9)<<tbc<<endl;
cout<<setw(34)<<"------"<<endl;
cout<<"Total passenger"<<setw(19)<<total<<endl;
cout<<setw(34)<<"======"<<endl;
system("pause");
return 0;
break;

case '2':case 'M':
for(int k=0;k<total;k++)
{
s[k]=1;
}
for(row;row<10;row++)
{
cout<<row<<" ";
for(int i=0;i<3;i++)
{
cout<<s[seat];
seat++;
}
cout<<endl;

}
cout<<endl;
break;

default:
cin.clear();
cin.ignore(250,'\n');
}
}while(c=='2'||c=='M');

}while(c!=1||c!='f'||c!=2||c!='M');


system("pause");
return 0;
}
Last edited on
It looks like you have an error in your code. Of course, no one is going to sift through that unformatted mess, so I would recommend putting code tags around all of the code. Also try describing what the code should do, what it actually does and the various attempts you've made at solving the problem. This IS your problem to solve, no one else's. While we are happy to help, we aren't just going to do all the work.
Topic archived. No new replies allowed.