I have a problem where I need to display a seating assignment for an airplane. It will have 13 rows and 6 columns. If the seats are empty, it should display * and if the seat is taken it should show an X. There will eventually be 3 different types of seats to choose from, but I'm just trying to get the first part working. I can get the initial array to show all empty seats, but I'm having problems getting the seats reserved, then displaying the array correctly. Here is my code...
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
char tickets [13] [6]; //array of 13 rows and 6 columns
char option;
int x;
int z;
int row;
char col;
int numOfCol;
int numOfRow;
char a = 'A';
int A;
char b = 'B';
int B;
char c = 'C';
int C;
char d = 'D';
int D;
char e = 'E';
int E;
char f = 'F';
int F;
A = a - 65; // |
B = b - 65; // |
C = c - 65; // | This is supposed to change the column letter to a number in the array
D = d - 65; // |
E = e -65; // |
F = f -65; // |
numOfCol = 6;
numOfRow = 13;
cout << setw(11) << "A" << setw(6) << "B" << setw(6) << "C" << setw(6) << "D" << setw(6) << "E" << setw(6) << "F" << endl;
for (x = 0; x < 13; x++) // |
for (z = 0; z < 6; z++) // | This sets the array to all *
tickets [x] [z] = '*'; // |
for (x = 0; x < numOfRow; x++) ///////////////////////|
{ ////////|
cout << "Row" << setw(3) << x +1 << ""; /////////// | This prints the array
for (z = 0; z < numOfCol; z++) /////////// |
cout << setw(5) << tickets [x] [z] << " "; //// |
cout << endl; //// |
} //////////|
cout << endl;
cout << "Would you like a first class seat? (Y/N)" << "";
cin >> option;
if (option == 'Y' || option == 'y')
{
cout << "Please enter the row number and seat letter you would like." << endl;
cout << "Row" << "";
cin >> row;
cout << "Seat letter" << "";
cin >> col;
tickets [row][col] = 'X'; // Trying to assign X to the corresponding row and column
cout << setw(5) << tickets [x] [z] << " "; // Display the array again
}
else if (option == 'N' || option == 'n')
{
cout << "Would you like an economy seat? (Y/N)" << "";
cin >> option;
if (option == 'Y' || option == 'y')
{
cout << "Please enter the row number and seat letter you would like." << endl;
cout << "Row" << "";
cin >> row;
cout << "Seat letter" << "";
cin >> col;
// assign seat
}
else cout << "Thank you for shopping." << endl;
}
return 0;
}