Question: COP 2 2 2 0 : Programming in CExam 2 - Hotel Reservations: ( 2 1 points ) This exam covers all material up to

COP 2220: Programming in CExam 2- Hotel Reservations: (21 points)This exam covers all material up to, and including, two-d arrays.Read ALL the following instructions CAREFULLY BEFORE writing any code. If you do not understand something, email me ASAP for clarification.Create a C program and save it as cop2220Exam2YourInitials.c in your cop2220 folder. Example: Fred Flintstone would save the file as cop2220Exam2FF.c(I will take off points if the file is not named exactly as required.)The program is designed to help the manager of a hotel keep track of room occupancy. The hotel will be represented by a two-d array (3 rows, 5 columns) of integer values. The rows represent the floors of the hotel with row 0 being the ground floor. The columns represent the rooms on each floor.The manager (the user) will be presented with a menu that will allow him/her to do the following:Add occupant(s) to a room.Remove occupant(s) from a room.Determine if a room is occupied and with how many occupants. Display the hotel room set up.Quit the program.The program will utilize functions as defined by the following prototypes and described after I describe the main function. The prototypes need to be placed above the main with the actual functions defined below the main.void initHotel(int hotel[][5);int menu();void processChoice(int hotel[][5], int choice); void checkRoomOccupancy(int hotel[][5]);void addOccupant(int hotel[][5]);Choice =1: Call thetwo-D parameter.Choice =2: Call thethe two-D parameter.COP 2220 Exam 2 Spring 2024 void removeOccupant(int hotel[][5]); void displayHotelSetup(int hotel[][5]);The algorithm for the main function follows: (Pay attention to indentation in the algorithm.)Declare a two-d array named hotel with 3 rows and 5 columns.Call the initHotel function and give it the hotel array as a parameter.Do:While the user's choice is not equal to whatever your quitting value is.The description of the initHotel function follows:Go through the two-D array parameter in row major order andassign 0 to each element of the array. The description of the menu function follows:Display the list of choices including the choice for quitting.Collect the choice from the user in an integer variable and return the value in that variable.The description of the processChoice function follows:Use a switch statement to determine what choice was passed into the function and based on the choice, do the following:Call the menu function and collect what it returns in avariable.Call the processChoice function and pass it the hotel array and the choice obtained from the menu. addOccupant function and give it the removeOccupant function and give it checkRoomOccupancy function and giveChoice =4: Call the displayHotelSetup function and give it the two-D parameter.Any other choice, display an invalid choice message.Choice =3: Call theit the two-D parameter.Page2of5COP 2220 Exam 2 Spring 2024The algorithm for the addOccupant function follows: (Pay attention to indentation in the algorithm.) Ask the user for a floor number between 0 and 2. If the number entered by the user is out of bounds Display an appropriate message. Else: Ask the user for a room number between 0 and 4. If the number entered by the user is out of bounds Display an appropriate message. Else: If the two-D array at that floor and room is not 0: Display a message saying that the room is already occupied. Else: Ask the user for the number of occupants. If that number is less than or equal to 0 or bigger than 5 display a message saying invalid number of occupants.Else: End if. End if. End if. End if.Assign the number of occupants to thetwo-D array that was passed in as aparameter using the floor and room asindexes into the array.Page3of5End if.COP 2220 Exam 2 Spring 2024The algorithm for the removeOccupant function follows: (Pay attention to indentation in the algorithm.) Ask the user for a floor number between 0 and 2. If the number entered by the user is out of bounds Display an appropriate message. Else: Ask the user for a room number between 0 and 4. If the number entered by the user is out of bounds Display an appropriate message. Else: Assign 0 to the two-D array that was passed in as a parameter using the floor and room as indexes into the array. End if. End if.The algorithm for the checkRoomOccupancy function follows: (Pay attention to indentation in the algorithm.) Ask the user for a floor number between 0 and 2. If the number entered by the user is out of bounds Display an appropriate message. Else: Ask the user for a room number between 0 and 4. If the number entered by the user is out of bounds Display an appropriate message. Else: If the number of occupants in the room is 0 Print that the room is empty.Else: End if. End if.Display the number of occupants with anappropriate message.Page4of5COP 2220 Exam 2 Spring 2024The description of the displayHotelSetup function follows:Display the contents of the two-D array parameter so that all the rooms on floor number 2 are displayed first, then all the rooms on floor 1, then all then rooms on floor 0. As an example, display each row as follows:Floor2: 30051 Floor1: 01204 Floor0: 40005[Note that to display the contents of a two-D array like this you will need two nested loops. The outer loop starts at 2 and goes up to 0. The inner loop starts at 0 and goes up to 4.]

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!