I find that my program is a bit too wordy and im not sure as to how i can make it into less line. Can someone help me please?
Code:
#include<iostream>
#include<string>
using namespace std;
void details( string fNum,int dHour,int dMin,int aHour,int aMin, string aircraft);
int main()
{
//Flights tB:Trinidad-Barbados,tN:Trinidad to New York,tL:Trinidad to London.
int dHour;
int dMin;
string fNum;
int aHour;
int aMin;
int durHour;
int durMin;
string aircraft;
int rows,columns;
int dOption;
bool availabe=true;
int tbSeats[15][4]={0};
int tnSeats[32][6]={0};
int tlSeats[30][10]={0};
int resAmt;
int empty=0;
//Recording Reservations for Passengers
cout<<"\nWhat is your destination?\n"<<endl<<"1) Trinidad to Barbados"<<endl
<<"2) Trinidad to New York"<<endl
<<"3) Trinidad to London\n"<<endl;
cout<<"Please enter either 1,2 or 3."<<endl;
cin>>dOption;
switch (dOption)
{
case 1:
dHour=7;
dMin=0;
fNum="USC 215";
aHour=7;
aMin=45;
durHour=0;
durMin=45;
aircraft="MD 82";
rows=15;
columns=4;
break;
case 2:
dHour=6;
dMin=0;
fNum="USC 400";
aHour=3;
aMin=0;
durHour=6;
durMin=0;
aircraft="Boeing 737";
rows=32;
columns=6;
break;
case 3:
dHour=7;
dMin=30;
fNum="USC 900";
aHour=9;
aMin=30;
durHour=9;
durMin=0;
aircraft="Boeing 777";
rows=30;
columns=10;
break;
}
details(fNum,dHour,dMin,aHour,aMin, aircraft);
//This section declares everything in all of the arrays to 0;
if (dOption==1)
{
int tbSeats[15][4]={0};
for(int a=0;a<rows;a++)
{
for(int b=0;b<columns;b++)
{
cout<<tbSeats[a][b]<<"\t";
}
cout<<endl;
} }
else if(dOption==2)
{
int tnSeats[32][6]={0};
for(int a=0;a<rows;a++)
{
for(int b=0;b<columns;b++)
{
cout<<tnSeats[a][b]<<"\t";
}
cout<<endl;
}
}
else if (dOption==3)
{
int tlSeats[30][10]={0};
for(int a=0;a<rows;a++)
{
for(int b=0;b<columns;b++)
{
cout<<tlSeats[a][b]<<"\t";
}
}
}
cout<<endl;
// This section determines how many empty seats there are
if (dOption==1)
{
for(int c=0;c<rows;c++)
{
for(int d=0;d<columns;d++)
{
if (tbSeats[c][d]==0)
empty++;
}
}
}
else if(dOption==2)
{
for(int c=0;c<rows;c++)
{
for(int d=0;d<columns;d++)
{
if (tnSeats[c][d]==0)
empty++;
}
}
}
else if (dOption==3)
{
for(int c=0;c<rows;c++)
{
for(int d=0;d<columns;d++)
{
if (tlSeats[c][d]==0)
empty++;
}
}
}
cout<<"There are "<<empty<<" empty seats"<<endl;
//This section takes the amount of seats that the user wishes to reserve and makes them unavailable
cout<<"How many seats would you like to reserve?"<<endl;
cin>>resAmt;
for (int e=0;e>resAmt;e++)
{
if (dOption==1)
{
for(int c=0;c<rows;c++)
{
for(int d=0;d<columns;d++)
{
if (tbSeats[c][d]==0)
{
tbSeats[c][d]=1;
}
else
{
cout<<"This seat is already taken"<<endl;
}
}
}
}
else if(dOption==2)
{
for(int c=0;c<rows;c++)
{
for(int d=0;d<columns;d++)
{
if (tnSeats[c][d]==0)
{
tnSeats[c][d]=1;
}
else
{
cout<<"This seat is already taken"<<endl;
}
}
}
}
else if (dOption==3)
{
for(int c=0;c<rows;c++)
{
for(int d=0;d<columns;d++)
{
if (tlSeats[c][d]==0)
{
tlSeats[c][d]=1;
}
else
{
cout<<"This seat is already taken"<<endl;
}
}
}
}
}
}
return 0;
}
void details( string fNum,int dHour,int dMin,int aHour,int aMin, string aircraft)
{
cout<<"\n\nYou Have Chosen to Fly on Flight Number "<<fNum<<endl;
cout<<"The Flight will Depart at "<<dHour<<":"<<dMin<<endl;
cout<<"The Flight will Arrive at its Destination in "<<aHour<<" Hours and "<<aMin<<" Minutes"<<endl;
cout<<"Aircraft is the "<<aircraft<<endl;
}