Question: To create a C program for managing hotel room occupancy using a two - dimensional array, follow these steps: 1 . Declare and initialize the
To create a C program for managing hotel room occupancy using a twodimensional array, follow these steps: Declare and initialize the twodimensional array: Declare an array named "hotel" with rows and columns. Implement the initHotel function to assign to each element of the array. Create a menu function: Implement a function called menu that displays the available choices add occupant, remove occupant, display occupancy, quit Collect the user's choice and return it as an integer. Process the user's choice: Implement the processChoice function that takes the user's choice and the hotel array as parameters. Use a switch statement to execute different actions based on the user's choice: If the choice is call the addOccupant function and pass the hotel array as a parameter. If the choice is call the removeOccupant function and pass the hotel array as a parameter. If the choice is call the displayHotelSetup function and pass the hotel array as a parameter. For any other choice, display an invalid choice message. Implement the addOccupant function: Prompt the user for a floor number between and If the number is out of bounds, display an appropriate message. Otherwise, prompt the user for a room number between and If the number is out of bounds, display an appropriate message. If the room is already occupied, display a message indicating that. Otherwise, ask the user for the number of occupants. If the number is less than or equal to or bigger than display an invalid number of occupants message. Assign the number of occupants to the corresponding element in the hotel array. Implement the removeOccupant function: Prompt the user for a floor number between and If the number is out of bounds, display an appropriate message. Otherwise, prompt the user for a room number between and If the number is out of bounds, display an appropriate message. Set the corresponding element in the hotel array to to indicate that the room is now unoccupied. Implement the displayHotelSetup function: Display the contents of the hotel array in the desired format. Use nested loops to iterate through the array, starting with the highest floor and going down to the ground floor. Within each floor, display the rooms from left to right.
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
