Assignment Description:

School is holding an award ceremony for outstanding students and inviting their family members.The staff in charge of this event, need to know the number of possible attendees to make proper arrangements.

Students need to sign in, staff need to first verify whether the student is on the awards list, and how many family members will accompany them and know about their possible preferential seatings. You are asked to write a program to facilitate this process.

The following is a list of information you need to know to write this program:

  • The school facility for ceremonies can seat maximum of 100 people in 10 rows of 10 seats.
  • Students can bring up to 5 guests with them to the ceremony.
  • The names along with the IDs of eligible students are provided in a file.
  • The list of students who have requested to register for the event, along with more information about the number of guests as well as their seating preferences are also listed in a file.
  • Your program should prompt the user for the names of both of these files at different points of this program.
  • The user will also be prompted for the number of the eligible students whose names and IDs are listed in a file.
  • A certain number of tickets goes to what we call VIPs, the user will be prompted for that number. These seats will be randomly assigned.

We start by prompting the user for the following information:

1. Please enter the number of students who are eligible to attend.
2. Please enter the file-name containing the names of the eligible students.
3. Please enter the number of VIP tickets:

Following the description of the seating space as well as the above interaction with the user, you have the information to create your data structures:

  • A 2d array of strings of size 10 by 10 to simulate our seating chart. You should call this 2d array just that: seatingChart. You must initialize this 2d array to the string literal: "000". "000" indicates an empty seat. Eventually, the strings populating this chart would be either the student IDs, "000"s or "VIP"s.
  • Declare a structure called Student, that has two strings as members: fullName, and ID. For the sake of this assignment we assume a 3-digit pattern for student IDs e.g. "123".
  • Another data structure that you will need is a dynamically allocated 1d array of type Student. Call this array name-IDList. We get the size of this array based on question #1.
  • A vector of type strings, that will be populated after processing the file containing the students' request to register. This vector will store the IDs of those students who could not be accommodated for any reason.

The following provides more explanations about the requirements of this program:

  • Question #2 asks the user for the name of the file that contains the names as well the IDs of eligible students. The number of lines in this file MUST match the number of students that the user will input for question #1. In this file on each line you will read two strings, the first one is the student ID, and the next is their full name. Here is an example line in this file:
453 Cynthia Rhodes
125 Marc Jones
. . .
  • The array name-IDList will be populated based on this file. Notice each line will be read as a Student (our structure).
  • The answer to question #3 will be used to randomly assign a number of seats to VIPs. This is done by randomly picking a row number and a column number (both in the range 0-9 inclusive) and store "VIP" in that cell throughout your 2d array. So at this point, the seating chart i.e. our 2d array of strings will include a number of "000"s as well as randomly populated "VIP"'s. The "000"s in this seating chart will be overwritten by students IDs after they are properly registered for the event.
  • The file that contains the information about the students who would like to attend contains the data in the EXACT following format:
[student's ID][space][Number of guests][space][-1, or a row number][Enter]

An example:

222 3 -1
178 0 2
. . .

The third item on each line is for student's seating preferences:

-1 indicates no preference, student and their party will be seated anywhere space is available. We look for a space sequentially starting from the first row and moving onwards. So the seating chart will be filled starting from the first row to the second, etc.

A row number in the range 0-9 indicates that the student and their party would like to be seated together and in a preferred row.

We do not know how many lines there will be in this file, and we do not need to know since we know how to code scenarios like this, Right?

In processing this file, you first should verify the following:

  • Student's ID is on the list of eligible students. (We have a populated dynamic array for this.)
  • The number of guests must be at most 5.
  • The preferential row number must be in the valid range of 0-9.

For the sake of brevity of your program, we can safely assume that there won't be any other anomalies outside the above cases.

The following lists the steps taken on each line in this file. Please note that upon a disqualifying element of this data you should move on to the next applicant.

  • Read the ID, search for it in the name_IDList array, and verify that the student is on the list. If the ID did not match any student on the list, add the ID to the vector, and move on to the next student. Must call the function isFound, with the following prototype:
bool isFound( Student *, int, string );
  • The parameters in the above function are: The name_IDs array, its size, and the student ID. If the ID was found in the array, it returns true, otherwise it returns false.
  • Next is the number of guests, verify that it is in the range 0-5. If not add the ID to the vector and move on to the next student.
  • Next is the seating preference. We are expecting either -1 or a number in the range 0-9 inclusive. Verify that. If the criteria is not met, add the ID to the vector and move on to the next student.
  • When all passed, you call either of the methods whose prototypes are given below:
***** void noPrefSeating(string [][colSize], int, string, int, vector < string> &);
  • These parameters in order are: the seating chart, the size of rows, the student ID, number of guests, and the vector to store the ID of the student in case they could not be accommodated due to lack of space.
***** void prefSeating(string [][colSize], int, string, int, int, vector < string> &);
  • These parameters in order are: the seating chart, the size of rows, the student ID, number of guests, the preferred row number, and the vector to store the ID of the student in case they could not be accommodated due to lack of space.

Your program will be based on the following menu:

Please choose an option:
1. Register for the event:
Please enter the file name:
2. Display the seating chart.
3. Which row has the most number of VIP tickets?
4. Display the list of IDs of those who could not be registered.
5. Exit.

Option 1. This option will follow another prompt for the user to input the name of the file. Your program then should process the contents of this file and seat the students who met the criteria, and populate the vector based on the IDs of those who did not.

Some important points about how to seat students and their guests:

One way of finding available seats based on user's seating preferences is to use a pointer!

Yes, a pointer! Let me see if I can convince you:

Let's say I have 3 guests and I would like to be seated in row #2. You can set up a loop that only iterates through seatingChart[2] row. When you focus on that specific row, you need to first look for the very first "empty" seat i.e. the one that contains "000". When you find that cell, you stop looping since you have some investigation to do: you have to see whether you have enough seats available in that row, and also whether they are all "000"s. Checking this dual-condition requires us "looking ahead" before making any assignment. This means that we dont want to make any changes to the seating chart unless we are sure we have the availability. This is where a pointer could help. Set up a pointer to where you first find an available spot, let the pointer go and check the lay of the land for you, let it march on the row and check the seats, count them and see whether they are available. And only after you made sure that you have the right number of seats available and adjacent to one another, you can REASSIGN the pointer to where you started and this time use it to modify your seating chart. When the pointer is done with its job, you can end the search loop.

You do not have to use a pointer, but I strongly recommend that you do!

In this option you MUST use the above mentioned functions based on the seating preferences or lack thereof.

Option 2. You MUST use a function whose prototype is given below:

void displaySeatingChart(string [][colSize], int);

Option 3. You MUST use a function whose prototype is given below:

void displayTheVector(vector < string>);

Option 4. Must use the following function. It simply looks for the maximum number of VIP seats in a row, and returns the row number.

int maxVIPRow(string [][colSize], int);

A sample run of this program with the files that I will upload along with this document is given as the last page here. Use it as a reference to make sure you understand the requirements of the assignment. Notice your output will be different as the VIP seats are randomly chosen and will be different every time you compile and run your program.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.