Question: COP 2 2 2 0 : Programming in CExam 2 - Hotel Reservations: ( 2 1 points ) This exam covers all material up to
COP : Programming in CExam Hotel Reservations: pointsThis exam covers all material up to and including, twod 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 copExamYourInitials.c in your cop folder. Example: Fred Flintstone would save the file as copExamFFcI 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 twod array rows, columns of integer values. The rows represent the floors of the hotel with row 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 himher to do the following:Add occupants to a room.Remove occupants from a room.Determine if a room is occupied and with how many occupants. Display the hotel room set upQuit 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 initHotelint hotel;int menu;void processChoiceint hotel int choice; void checkRoomOccupancyint hotel;void addOccupantint hotel;Choice : Call thetwoD parameter.Choice : Call thethe twoD parameter.COP Exam Spring void removeOccupantint hotel; void displayHotelSetupint hotel;The algorithm for the main function follows: Pay attention to indentation in the algorithm.Declare a twod array named hotel with rows and 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 isThe description of the initHotel function follows:Go through the twoD array parameter in row major order andassign 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 : Call the displayHotelSetup function and give it the twoD parameter.Any other choice, display an invalid choice message.Choice : Call theit the twoD parameter.PageofCOP Exam Spring The algorithm for the addOccupant function follows: Pay attention to indentation in the algorithm. Ask the user for a floor number between and If the number entered by the user is out of bounds Display an appropriate message. Else: Ask the user for a room number between and If the number entered by the user is out of bounds Display an appropriate message. Else: If the twoD array at that floor and room is not : 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 or bigger than display a message saying invalid number of occupants.Else: End if End if End if End ifAssign the number of occupants to thetwoD array that was passed in as aparameter using the floor and room asindexes into the array.PageofEnd ifCOP Exam Spring The algorithm for the removeOccupant function follows: Pay attention to indentation in the algorithm. Ask the user for a floor number between and If the number entered by the user is out of bounds Display an appropriate message. Else: Ask the user for a room number between and If the number entered by the user is out of bounds Display an appropriate message. Else: Assign to the twoD array that was passed in as a parameter using the floor and room as indexes into the array. End if End ifThe algorithm for the checkRoomOccupancy function follows: Pay attention to indentation in the algorithm. Ask the user for a floor number between and If the number entered by the user is out of bounds Display an appropriate message. Else: Ask the user for a room number between and 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 Print that the room is empty.Else: End if End ifDisplay the number of occupants with anappropriate message.PageofCOP Exam Spring The description of the displayHotelSetup function follows:Display the contents of the twoD array parameter so that all the rooms on floor number are displayed first, then all the rooms on floor then all then rooms on floor As an example, display each row as follows:Floor: Floor: Floor: Note that to display the contents of a twoD array like this you will need two nested loops. The outer loop starts at and goes up to The inner loop starts at and goes up to
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
