Hi, I would like to ask something about multi-dimensional array. Recently i got an assignment that request me to write a program for airplane ticket reservation. The question is as follows:
This program assigns seats for a commercial airplane.
The current seat assignment is as follows.
A B C D E F
Row 1 * * * * * *
Row 2 * * * * * *
Row 3 * * * * * *
Row 4 * * * * * *
Row 5 * * * * * *
Row 6 * * * * * *
Row 7 * * * * * *
Row 8 * * * * * *
Row 9 * * * * * *
Row 10 * * * * * *
Row 11 * * * * * *
Row 12 * * * * * *
Row 13 * * * * * *
* -- available seat
X -- occupied seat
Rows 1 and 2 are for first class passengers.
Rows 3 through 7 are for business class passengers.
Rows 8 through 13 are for economy class passengers.
To reserve a seat enter Y/y (Yes), N/n(No):
Y
Enter ticket type: F/f (first class); (B/b) (business class); E/e (economy class) : f
Enter Row number 1 – 2: 1
Enter seat number (A – F): A
This seat is reserved for you
A B C D E F
Row 1 X * * * * *
Row 2 * * * * * *
Row 3 * * * * * *
Row 4 * * * * * *
Row 5 * * * * * *
Row 6 * * * * * *
Row 7 * * * * * *
Row 8 * * * * * *
Row 9 * * * * * *
Row 10 * * * * * *
Row 11 * * * * * *
Row 12 * * * * * *
Row 13 * * * * * *
* -- available seat
X -- occupied seat
This program assigns seats for a commercial airplane.
The current seat assignments is as follows.
A B C D E F
Row 1 X * * * * *
Row 2 * * * * * *
Row 3 * * * * * *
Row 4 * * * * * *
Row 5 * * * * * *
Row 6 * * * * * *
Row 7 * * * * * *
Row 8 * * * * * *
Row 9 * * * * * *
Row 10 * * * * * *
Row 11 * * * * * *
Row 12 * * * * * *
Row 13 * * * * * *
* -- available seat
X -- occupied seat
Rows 1 and 2 are for first class passengers.
Rows 3 through 7 are for business class passengers.
Rows 8 through 13 are for economy class passengers.
Reserve another seat Y/y(yes), N/n(No): n
The bold is user input. I currently successful to make an output shown as above, but the problem I encountered is that I can't assign the asterisks and "X" in a character form, if I do so, it gives me something like hexadecimal or octal code, as shown below:
This program assigns seats for a commercial airplane.
The current seat assignment is as follows.
A B C D E F
Row 1 * * * * * *
Row 2 * * * * * *
Row 3 * * * * * *
Row 4 * * * * * *
Row 5 * * * * * *
Row 6 * * * * * *
Row 7 * * * * * *
Row 8 * * * * * *
Row 9 * * * * * *
Row 10 * * * * * *
Row 11 * * * * * *
Row 12 * * * * * *
Row 13 * * * * * *
* -- available seat
X -- occupied seat
Rows 1 and 2 are for first class passengers.
Rows 3 through 7 are for business class passengers.
Rows 8 through 13 are for economy class passengers.
To reserve a seat enter Y/y (Yes), N/n(No):
y
Enter ticket type: F/f (first class); (B/b) (business class); E/e (economy class
) :f
Enter Row number 1 û 2: 1
Enter Seats A - F: a
The seats is reserved for you.
A B C D E F
Row 1 0012FEE0 0012FEE0 0012FEE0 0012FEE0
0012FEE0 0012FEE0
Row 2 0012FEE0 0012FEE0 0012FEE0 0012FEE0
0012FEE0 0012FEE0
Row 3 0012FEE0 0012FEE0 0012FEE0 0012FEE0
0012FEE0 0012FEE0
Row 4 0012FEE0 0012FEE0 0012FEE0 0012FEE0
0012FEE0 0012FEE0
Row 5 0012FEE0 0012FEE0 0012FEE0 0012FEE0
0012FEE0 0012FEE0
Row 6 0012FEE0 0012FEE0 0012FEE0 0012FEE0
0012FEE0 0012FEE0
Row 7 0012FEE0 0012FEE0 0012FEE0 0012FEE0
0012FEE0 0012FEE0
Row 8 0012FEE0 0012FEE0 0012FEE0 0012FEE0
0012FEE0 0012FEE0
Row 9 0012FEE0 0012FEE0 0012FEE0 0012FEE0
0012FEE0 0012FEE0
Row 10 0012FEE0 0012FEE0 0012FEE0 0012FEE0
0012FEE0 0012FEE0
Row 11 0012FEE0 0012FEE0 0012FEE0 0012FEE0
0012FEE0 0012FEE0
Row 12 0012FEE0 0012FEE0 0012FEE0 0012FEE0
0012FEE0 0012FEE0
Row 13 0012FEE0 0012FEE0 0012FEE0 0012FEE0
0012FEE0 0012FEE0
Press any key to continue . . .
Currently I just do for the first section. And can anyone help me to solve my problem out. My code are as follows:
After putting the subscript in it, yet it still give me some of the error during debug time. such as variable being used without determined. How can I counter that problems?
This program assigns seats for a commercial airplane.
The current seat assignment is as follows.
A B C D E F
Row 1 * * * * * *
Row 2 * * * * * *
Row 3 * * * * * *
Row 4 * * * * * *
Row 5 * * * * * *
Row 6 * * * * * *
Row 7 * * * * * *
Row 8 * * * * * *
Row 9 * * * * * *
Row 10 * * * * * *
Row 11 * * * * * *
Row 12 * * * * * *
Row 13 * * * * * *
* -- available seat
X -- occupied seat
Rows 1 and 2 are for first class passengers.
Rows 3 through 7 are for business class passengers.
Rows 8 through 13 are for economy class passengers.
To reserve a seat enter Y/y (Yes), N/n(No):
y
Enter ticket type: F/f (first class); (B/b) (business class); E/e (economy class
) :f
Enter Row number 1 û 2: 1
Enter Seats A - F: a
The seats is reserved for you.
A B C D E F
Row 1 ╠ ╠ ╠ ╠ ╠ ╠
Row 2 * ╠ ╠ ╠ ╠ ╠
Row 3 ╠ ╠ ╠ ╠ ╠ ╠
Row 4 ╠ ╠ ╠ ╠ ╠ ╠
Row 5 ╠ ╠ ╠ ╠ ╠ ╠
Row 6 ╠ ╠ ╠ ╠ ╠ ╠
Row 7 ╠ ╠ ╠ ╠ ╠ ╠
Row 8 ╠ ╠ ╠ ╠ ╠ ╠
Row 9 ╠ ╠ ╠ ╠ ╠ ╠
Row 10 ╠ ╠ ╠ ╠ ╠ ╠
Row 11 ╠ ╠ ╠ ╠ ╠ ╠
Row 12 ╠ ╠ ╠ ╠ ╠ ╠
Row 13 ╠ ╠ ╠ ╠ ╠ ╠
Press any key to continue . . .
this is what i get after i edited in the subscript part. Can anyone tell me what is the solution for this?
Also remove \ from following line, this is an invalid escape code, notice your output is 1 û 2: instead of 1 - 2:
<< "Enter Row number 1 \– 2: ";
to << "Enter Row number 1 – 2: ";
Also you are defining char reserved[2]; and assigning reserverd[2] = 'X', which is off the end of the array. Valid array entries are 0 and 1. You don't need this to be an array. Make it a single char.