Question: Please use the following code which already has most of the user interface set up: https://www.cs.uic.edu/pub/CS211/ProjectS18/proj4base.c Additionally here is the text: /* Code for the

 Please use the following code which already has most of theuser interface set up: https://www.cs.uic.edu/pub/CS211/ProjectS18/proj4base.c Additionally here is the text: /* Codefor the user interface for Lab 4 for CS 211 Fall 2015 Please use the following code which already has most of the user interface set up:

https://www.cs.uic.edu/pub/CS211/ProjectS18/proj4base.c

Additionally here is the text:

/* Code for the user interface for Lab 4 for CS 211 Fall 2015 * * Author: Pat Troy * Date: 10/6/2013 */ #include  #include  #include  typedef enum {FALSE = 0, TRUE, NO = 0, YES} boolean; /* forward definition of functions */ void clearToEoln(); /* Read in until the first Non-White-Space character is Read */ /* The white space characters are: * space, tab \t, newline , vertical tab \v, * form feed \f, and carriage return */ int getNextNWSChar () { int ch; ch = getc(stdin); if (ch == EOF || ch == ' ') return ch; while (isspace (ch)) { ch = getc(stdin); if (ch == EOF || ch == ' ') return ch; } return ch; } /* read in the next Positive Integer or error: */ /* This is based on the Mathematical definition of a Postive Integer */ /* zero is not counted as a positive number */ int getPosInt () { int value = 0; /* clear white space characters */ int ch; ch = getc(stdin); while (!isdigit(ch)) { if (' ' == ch) /* error ==> no integer given */ return 0; if (!isspace(ch)) /* error non white space ==> integer not given next */ { clearToEoln(); return 0; } ch = getc(stdin); } value = ch - '0'; ch = getc(stdin); while (isdigit(ch)) { value = value * 10 + ch - '0'; ch = getc(stdin); } ungetc (ch, stdin); /* put the last read character back in input stream */ /* Integer value of 0 is an error in this program */ if (0 == value) clearToEoln(); return value; } /* read in the name until the end of the input */ char *getName() { /* skip over the white space characters */ int ch; ch = getc(stdin); while (isspace(ch)) { if (' ' == ch) /* error ==> no integer given */ return NULL; ch = getc(stdin); } char *word; int size; size = 10; word = (char *) malloc (sizeof(char) * size); // read in character-by-character until the newline is encountered int count = 0; while (ch != ' ') { if (count+1 >= size) { // to grow an array to make it "dynamically sized" using malloc char* temp; int i; size = size * 2; temp = (char *) malloc (sizeof(char) * size); // printf ("Growing array from size %d to size %d ", count, size); // copy the characters to the new array for (i = 0 ; i  30) { count = 30; word[count] = '\0'; } /* clear ending white space characters */ while (isspace (word[count-1])) { count--; word[count] = '\0'; } return word; } /* Clear input until next End of Line Character - */ void clearToEoln() { int ch; do { ch = getc(stdin); } while ((ch != ' ') && (ch != EOF)); } /* Print out a list of the commands for this program */ void printCommands() { printf ("The commands for this program are: "); printf ("q - to quit the program "); printf ("? - to list the accepted commands "); printf ("a   - to add a group to the wait list "); printf ("c   - to add a call-ahead group to the wait list "); printf ("w  - to specify a call-ahead group is now waiting in the restaurant "); printf ("r  - to retrieve the first waiting group that can fit at the available table size "); printf ("l  - list how many groups are ahead of the named group "); printf ("d - display the wait list information "); /* clear input to End of Line */ clearToEoln(); } void doAdd () { /* get group size from input */ int size = getPosInt(); if (size   "); printf (" where:  is the size of the group making the reservation "); printf ("  is the name of the group making the reservation "); return; } /* get group name from input */ char *name = getName(); if (NULL == name) { printf ("Error: Add command requires a name to be given "); printf ("Add command is of form: a   "); printf (" where:  is the size of the group making the reservation "); printf ("  is the name of the group making the reservation "); return; } printf ("Adding In-restaurant group \"%s\" of size %d ", name, size); // add code to perform this operation here } void doCallAhead () { /* get group size from input */ int size = getPosInt(); if (size   "); printf (" where:  is the size of the group making the reservation "); printf ("  is the name of the group making the reservation "); return; } /* get group name from input */ char *name = getName(); if (NULL == name) { printf ("Error: Call-ahead command requires a name to be given "); printf ("Call-ahead command is of form: c   "); printf (" where:  is the size of the group making the reservation "); printf ("  is the name of the group making the reservation "); return; } printf ("Adding Call-ahead group \"%s\" of size %d ", name, size); // add code to perform this operation here } void doWaiting () { /* get group name from input */ char *name = getName(); if (NULL == name) { printf ("Error: Waiting command requires a name to be given "); printf ("Waiting command is of form: w  "); printf (" where:  is the name of the group that is now waiting "); return; } printf ("Call-ahead group \"%s\" is now waiting in the restaurant ", name); // add code to perform this operation here } void doRetrieve () { /* get table size from input */ int size = getPosInt(); if (size  "); printf (" where:  is the size of the group making the reservation "); return; } clearToEoln(); printf ("Retrieve (and remove) the first group that can fit at a tabel of size %d ", size); // add code to perform this operation here } void doList () { /* get group name from input */ char *name = getName(); if (NULL == name) { printf ("Error: List command requires a name to be given "); printf ("List command is of form: l  "); printf (" where:  is the name of the group to inquire about "); return; } printf ("Group \"%s\" is behind the following groups ", name); // add code to perform this operation here } void doDisplay () { clearToEoln(); printf ("Display information about all groups "); // add code to perform this operation here } int main (int argc, char **argv) { char *input; int ch; printf ("Starting Restaurant Wait List Program "); printf ("Enter command: "); while ((ch = getNextNWSChar ()) != EOF) { /* check for the various commands */ if ('q' == ch) { printf ("Quitting Program "); return (0); } else if ('?' == ch) { printCommands(); } else if('a' == ch) { doAdd(); } else if('c' == ch) { doCallAhead(); } else if('w' == ch) { doWaiting(); } else if('r' == ch) { doRetrieve(); } else if('l' == ch) { doList(); } else if('d' == ch) { doDisplay(); } else if(' ' == ch) { /* nothing entered on input line * * do nothing, but don't give error */ } else { printf ("%c - in not a valid command ", ch); printf ("For a list of valid commands, type ? "); clearToEoln(); } printf (" Enter command: "); } printf ("Quiting Program - EOF reached "); return 1; } 

Restaurant Waiting List System For this lab, write a C program that will implement a customer waiting list that might be used by a restaurant. When people want to be seated in the restaurant, they give their name and group size to the host/hostess and then wait until those in front of them have been seated. The program must use a linked list to implement the queue-like data structure The linked list is to maintain the following information for each group that is waiting: name (we assume a maximum name length of 30 characters) group size in-restaurant status: whether the group has called ahead or is waiting in the restaurant The system does not take reservations for a specific time and date (i.e. table of 4 for 7pm on Saturday), but it will allow for a group to call ahead and get their name on the waiting list before they arrive. Note: these call-ahead groups will still need to check in when they arrive so the host/hostess knows they are waiting in the restaurant. Groups are added to the wait list when they call-ahead or when they arrive at the restaurant. Groups are always added to the end of the wait list. The system will require that each name used be unique. So when a group is added to the wait list, the system must make sure that no other group is already using that name When a table with N seats becomes available in the restaurant, the system returns the name of the first group that is in the restaurant and can sit at a table with N seats (i.e. the number of seats at the table is greater than or equal to the number of people in that group). Note that the group selected may not be the first (or even the second or third) group on the wait list This program will NOT keep track of how many tables the restaurant actually has, nor how many people can sit at each table. The host/hostess is expected to know that information and will enter the appropriate values when needed. The commands used by this system are listed below and are to come from standard input. Your program is to prompt the user for input and display error messages for unknown commands or improperly formatted commands. Note that the name of the group when given will be given as the last item on the input line. The name of the group may contain white space characters in the middle of the name but not at the beginning or end of the name. Each command given must display some information about the command being performed. Code to implement this interface is provided in the program proj4base.c Command Description Quit the List the commands used by this program and a brief description of how to use each one am a

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!