I have a character array 12x10. The array simply needs to contain an O or X to indicate if the seat is occupied. Here is what I have so far, I'll just share the whole assignment.
CSIS 123 – Chapter 8 - Arrays
Extra Credit Programming Projects – Movie Ticket Reservations
Here’s your assignment:
Create a program ON YOUR OWN that:
1. Write a program in VS17 that can be used to assign seats for the local movie theater. The theater has 12 rows with ten seats in each row. Rows 1-4 are reserved for the movie lover VIP patrons, rows 5 through 8 are prime seating, and rows 9 – 12 are discount seating
2. Initially, display all seats on the theater as follows:
A B C D E F G H I J
Row 1 O O O O O O O O O O
Row 2 O O O O O O O O O O
Row 3 O O O O O O O O O O etc for all 12 rows.
“O” reflects an “Open” seat.
3. For as long as there are seats available on the theater, your program will need to prompt the user for the following information:
• Ticket Type (VIP, Prime, Discount)
• Desired Row – only offer the rows that are part of that type of ticket group
• Desired Seat (A, B, C ….. J)
4. Before asking them for which seat they would like, check to see that there are still seats available in that section of the plane. If all seats in that section have been sold, display an appropriate message and re-prompt for ticket type.
5. Once a seat has been selected, check to ensure it’s available. If so, mark it sold by replacing the “O” with an “X” and then redisplay the seating plan for the plane. If not, message that it’s already sold, re-display the seating plan, and re-prompt for the desired seat assignment.
Your program MUST contain a main driver function and at least three other functions, each with a specific purpose. Use appropriate parameters to pass information in and out of each function. Do not use any global variables. Global CONSTANTS are perfectly fine. Tracking and display of seat sales must use a multi-dimensional array (2 or more dimensions)
Be sure to include LOTS of quality comments throughout your program. The first line should include a comment showing name of program, your name and date. Following that, describe in detail, what the program’s purpose is and basic functionality/structure. Each function should have header comments as well as comments for key processing and variables embedded in the function.
};
for (int i = 0; i < 12; i++) {
cout << setw(8) << "Row " << setw(2) << i + 1 << ": ";
for (int j = 0; j < 10; j++)
{
cout << setw(1) << left << seating[i][j] << setw(3) << setfill(' ') << right << " | ";
}
cout << endl;
}
if (vacancy == true) {
cout << "What is your ticket type? VIP is V, Prime is P, or Discount is D:" << endl;
cin >> ticketType;
}
else
{
cout << "ALL FULL, SORRY!" << endl;
};
switch (ticketType) {
case 'V':
cout << setw(1) << left << " A B C D E F G H I J" << endl << right << endl;
for (int i = 0; i < 4; i++) {
cout << setw(8) << "Row " << setw(2) << i + 1 << ": ";
for (int j = 0; j < 10; j++)
{
cout << setw(1) << left << seating[i][j] << setw(3) << setfill(' ') << right << " | ";
}
cout << endl;
}
cout << "These are the available seats. Which row would you like?" << endl;
cin >> desiredRow;
cout << "Which seat? A-J" << endl;
cin >> desiredSeat;
break;
case 'P':
cout << setw(1) << left << " A B C D E F G H I J" << endl << right << endl;
for (int i = 0; i > 3 && i < 8; i++) {
cout << setw(8) << "Row " << setw(2) << i + 1 << ": ";
for (int j = 0; j < 10; j++)
{
cout << setw(1) << left << seating[i][j] << setw(3) << setfill(' ') << right << " | ";
}
cout << endl;
}
cout << "These are the available seats. Which row would you like?" << endl;
cin >> desiredRow;
cout << "Which seat? A-J" << endl;
cin >> desiredSeat;
break;
case 'D':
cout << setw(1) << left << " A B C D E F G H I J" << endl << right << endl;
for (int i = 0; i > 8 && i < 12; i++) {
cout << setw(8) << "Row " << setw(2) << i + 1 << ": ";
for (int j = 0; j < 10; j++)
{
cout << setw(1) << left << seating[i][j] << setw(3) << setfill(' ') << right << " | ";
}
cout << endl;
}
cout << "These are the available seats. Which row would you like?" << endl;
cin >> desiredRow;
cout << "Which seat? A-J" << endl;
cin >> desiredSeat;
break;
default: cout << "Invalid option!";
}
system("pause");
return 0;
}
Sorry if this post is too long, I'm new here I don't really know the rules. But basically this is what I have and I'm beating my head against a wall. It seems ridiculous to type out every single spot, there must be an easier way.
Thanks!
Please, could you format your code? Press 'Edit' at the lower right corner of your code an select at the Format: column the '<>' for letting your code getting formatted. Don't forget to indent the code appropriately.