#include <iostream>
#include <cstring>
using namespace std;

int main()
{
    int i,n,len;
    char x[3];
    char status[15];

   cout<<"This is an airplane passengers seats program"<<endl<<endl;

   for(n=1;n<=7;n++){
   cout<<n<<" \tA\tB\tC\tD"<<endl<<endl;
   }

   cout<<"Please enter your seat accordingly : ";
   cin.getline(x,3);
   cout<<endl;
   len=strlen(x);

  // for (i=0;i<=len;i++)
  // x[i]=toupper(x[i]);

   for(int j=1;j<=7;j++){
   cout<<j<<" \tA\tB\tC\tD"<<endl<<endl;
   }





   cout<<"Thank you for using this program"<<endl;
   cout<<"Have a nice day"<<endl;

   system("pause");
   return 0;
}

Edited 3 Years Ago by Reverend Jim: Fixed formatting

You can look over this and see what is going on but as you will notice I commented in most of the stuff it is missing from being complete.

#include <iostream>
using namespace std;

void DisplaySeats( char seats[][4], int rows )
{
	for( int i = 0; i < rows; i++ )
	{
		cout << i+1 << " ";
		for( int c = 0; c < 4; c++ )
			cout << seats[i][c] << " ";
		cout << endl;
	}
	cout << endl;
}

int main()
{
	string input;
	int rows = 7; //amount of rows
	char seats[rows][4]; //holds seat information
	char aRow[] = {'A', 'B', 'C', 'D' }; //only used to assign seats array

	for( int i = 0; i < rows; i++ )
		for( int c = 0; c < 4; c++ )
			seats[i][c] = aRow[c]; //assigns the seats array

	DisplaySeats(seats, rows); //displays the seats

	//start a loop here

	cout << "Please enter your seat (i.e. 4B):" << endl; //include some way to break the loop
	getline(cin, input);

	//come up with better error checking and maybe remove all spaces for cases if someone types "4 B" instead of "4B"
	//does not check if seat is already taken
	if( input.length() < 2 ) //if input is too short (doesnt check if its too long)
	{
		cout << "invalid input" << endl;
		system("PAUSE");
		return 0;
	}

	if(( input[0] < (int)'1' || input[0] > (int)'7' ) || ( input[1] < (int)'A' || input[1] > (int)'D')) //checks if the input is ok (doesnt change the [0] index check if the rows are increased
	{
		cout << "invalid input" << endl;
		system("PAUSE");
		return 0;
	}

	seats[input[0]-(int)'0'][input[1]-(int)'A'] = 'X'; //based on input changes the seat in the array to an 'X'

	//end a loop here

	DisplaySeats(seats, rows);


	system("PAUSE");
	return 0;
}
This article has been dead for over six months. Start a new discussion instead.