1. Use two-dimensional array with size 7 columns and 5 rows.
  2. Seat numbers are populated during run-time.
  3. User is asked to input a seat number.
  4. Seat number chosen is replaced by 0.
  5. Program displays a remark “Seat successfully reserved” when reservation is done.
  6. User is not allowed to reserve a previously reserved seat. Display “Seat is taken” remarks.
  7. User is not allowed to enter an invalid seat number. Display an error message.
  8. Program continuously loops.

Recommended Answers

All 3 Replies

This problem most likely is from some textbook, unless I am misreading things, as shows up on CourseHero under two different courses by separate professors.

commented: That's good to know. My answer would change to review your coursework leading up to this assignment. +15

TBH, the assignment is pretty sparse as given; just what the program is supposed to be doing isn't entirely clear, but it seems to be a seating assignment chart, where each seat is a value in a two-dimentional array. The program starts by setting the values of the seats in the array as some arbitrary integer, presumably the count of the seat. Then each assignee (student, employee, whatever) requests a seat location, which the program checks against existing assignments. If the seat is available, its value in the replaced with a zero. If that seat is already assigned, then the program prints out a statement that there's no available seat. If the value requested isn't valid, then an error message is printed. The program continues looping on this data entry until the program is killed.

This having been said, the first step is clear: write a skeleton main() function and declare a 7x5 array of integers. That will at least get some code started.

For the rest, you would write a nested loop which populates the array, followed by a separate loop which gets the input from the user, checks for validity, iterates through the array for the requested seating and either sets that seat to zero or returns the message that it was already assigned.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.