Needs to be in basic pseudocode. 3) The seating map for a particular performance
ID: 3869039 • Letter: N
Question
Needs to be in basic pseudocode.
3) The seating map for a particular performance at a theater contains 70 rows of 100 seats each.
Assume that the following declarations have been made:
num desiredRowNumber
num desiredSeatNumber
num currentRow
num currentSeat
num rowSeatsReserved
num totalSeatsReserved
num seatsAvailable
a) Declare any other variables and constants needed and a 2-dimensional array to represent the seating map. This seating map applies only to this particular show. For other shows, the seating map may contain a different number of rows and seats per row, and the program must be capable of being modified for those by editing only two lines of code. Page 3 of 3
b) Allow a user to continuously enter a row number and seat number until they enter an appropriate sentinel value for the row number in order to stop entering input. Each time the user enters a valid row and seat number, the program determines if that seat is available, and if so, marks it as reserved with an “X” (available seats are not marked in any way). If the seat is not available, the program informs the user of this.
c) Once the user quits, the program outputs
i) each row number followed by the seat numbers in that row that have been reserved
ii) the total number of reserved seats
iii) the total number of available seats
Explanation / Answer
ROW = 10
COL = 17
seatMap = new char[ROW, COL]
void alocateSeat() {
while (true) {
[r,c]read(row and col of seat)
if (bookseat[r,c])
pring booked seat
else
print seat not available;
exit loop on usr request
}
}
int bookseat(int row, int col) {
if (row < 0 || row >=ROW || col < 0 || col >=COL)
return 0;
if (seatMap[row, col] != 'X') {
seatMap[row, col] = 'X';
return 1;
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.