Question: Create an event seating program from provided starter code Using C not C++ Create a program that reads in attendees' information, and create event seating

Create an event seating program from provided starter code Using C not C++

Create a program that reads in attendees' information, and create event seating with a number of rows and columns specified by a user. Then it will attempt to assign each attendee to a seat in an event.

Use the file event.c included. Complete the file and include all the following requested code in the file event.c

First, you need to create a structure attendee. It should contain two variables, last_name (char [30]) and first_name (char [30]). In addition, the following functions should be defined.

Function Description
void attendee_init_default (struct attendee *a) Assign the default string " ??? " to both variables, last_name and first_name.
void attendee_init (struct attendee *a, char *info) Use the strtok function to extract first name and last name from the variable attendee, then assign them to each instance variable of the attendee structure. An example of the input string is: Peter/Gabrial
void attendee_to_string (struct attendee *a) It prints the initial character of the first name, a period, the initial character of the last name, and a period. An example of such string for the guest Peter Gabrial is: D.J.

Then

You will be creating a structure called auditorium_seating in the same code file. The structure event_seating will contain a 2-dimensional array called "seating" of attendee type. Define the following functions:

Function Description
void event_seating_init (int rowNum, int columnNum, struct event_seating *e ) It instantiates a two-dimensional array of the size "rowNum" by "columnNum" specified by the parameters inside the struct a. Then it initializes each attendee element of this array using the attendee_init function. So, each attendee will have default values for its instance variables.
int assign_attendee_at (int row, int col, struct event_seating *a, struct attendee* a) The function attempts to assign the "a" to the seat at "row" and "col" (specified by the parameters of this function). If the seat has a default attendee, i.e., a attendee with the last name "???" and the first name "???", then we can assign the new attendee "a" to that seat and the method returns true. Otherwise, this seat is considered to be taken by another attendee else, the method does not assign the attendee and return 0 (false).
int check_boundaries (int row, int col, struct event_seating *e) The function checks if the parameters row and col are valid. If at least one of the parameters "row" or "col" is less than 0 or larger than the last index of the array (note that the number of rows and columns can be different), then it return 0 (false). Otherwise it returns 1 (true).
void event_seating_to_string (struct event_seating *a )

It prints information of the "seating". It should show the list of attendees assigned to the seating using the attendee_to_string function (it shows initials of each attendee) and the following format:

The current seating -------------------- P.G. ?.?. M.M.. ?.?. ?.?. L.M. M.C. U.T. ?.?.

event.c

#include struct attendee { char last_name[30] ; char first_name[30]; }; struct event_seating { struct attendee **seating; };

void attendee_init_default (struct attendee *g ) {} void attendee_init (struct attendee *g, char *info) {} void attendee_to_string (struct attendee *g ) {} void event_seating_init (int rowNum, int columnNum, struct event_seating *a ) {} int assign_attendee_at (int row, int col, struct event_seating *a, struct attendee* g) {} int check_boundaries (int row, int col, struct event_seating *a) {} void event_seating_to_string (struct event_seating *a ) {}

void main() { struct event_seating event_seating; struct attendee temp_attendee;

int row, col, rowNum, columnNum;

char attendee_info[30];

// Ask a user to enter a number of rows for an event seating printf ("Please enter a number of rows for an event seating."); scanf ("%d", &rowNum);

// Ask a user to enter a number of columns for an event seating printf ("Please enter a number of columns for an event seating."); scanf ("%d", &columnNum); // event_seating event_seating_init(rowNum, columnNum, &event_seating);

printf("Please enter a attendee information or enter \"Q\" to quit."); /*** reading a attendee's information ***/ scanf ("%s", attendee_info); /* we will read line by line **/ while (1 /* change this condition*/ ){ printf (" A attendee information is read."); // printing information. printf ("%s", attendee_info); // attendee attendee_init (&temp_attendee, attendee_info); // Ask a user to decide where to seat a attendee by asking // for row and column of a seat printf ("Please enter a row number where the attendee wants to sit."); scanf("%d", &row); printf("Please enter a column number where the attendee wants to sit."); scanf("%d", &col); // Checking if the row number and column number are valid // (exist in the theatre that we created.) if (check_boundaries(row, col, &event_seating) == 0) { printf(" row or column number is not valid."); printf("A attendee %s %s is not assigned a seat.", temp_attendee.first_name, temp_attendee.last_name); } else { // Assigning a seat for a attendee if (assign_attendee_at(row, col, &event_seating, &temp_attendee) == 1){ printf(" The seat at row %d and column %d is assigned to the attendee",row, col); attendee_to_string(&temp_attendee); event_seating_to_string(&event_seating); } else { printf(" The seat at row %d and column %d is taken.", row, col); } } // Read the next attendeeInfo printf ("Please enter a attendee information or enter \"Q\" to quit."); /*** reading a attendee's information ***/ scanf("%s", attendee_info); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!