28.7k views
2 votes
ABC Resort and Hotel has approached you to write a program to keep track of the number of rooms needed for an event. Customers can request any one of the following types of rooms to be reserved. Because the hotel has limited rooms available for a given event, it can only reserve up to 39 rooms. However, the hotel does not know how many rooms, in total, will be reserved because the rooms are reserved on demand.

Create a program for use by the hotel staff to take reservation orders for rooms for an event. All events are single night stay events. So you do not need to worry about the number of nights they are staying. An order occurs when the user enters a room type by name (e.g. Single). Until the user has indicated they are finished entering room types, continue to prompt the user to enter a room type. You must validate the room type, providing an error message and re-prompting the user if an invalid room type is entered. Keep track of the number of rooms that will be reserved for each room type.

Room Type Price/per night
Single $79.95
Single Deluxe $99.95
Double $149.95
Double Deluxe $179.95

Once the user has indicated they are finished entering room types, display a well-formatted report containing a list of each room type with its associated price, the number of rooms needed for that room type, the total revenue from all rooms for the event, and the average revenue from a room for the event.
Your solution must demonstrate the concept of one-dimensional arrays.
Solution Design:
1) Create a defining diagram that shows the input, processing, and output.
2) Create a solution algorithm using pseudocode.
3) Show testing using the desk checking table method, to include test data, expected results, and a desk checking table. Make sure your desk checking considers multiple cases including both valid and invalid test data to prove your algorithm will work in all cases.

User Alexisvt
by
4.5k points

1 Answer

5 votes

Answer:

Check the explanation

Step-by-step explanation:

/ Pseudocode for tracking the reservation of rooms for an event

Declaration

string roomInput;

string roomNames[4];

number roomPrice[4];

number roomCount[4];

number i;

boolean roomFound;

number totalRevenue, avgRevenue;

number totalRoomsNeeded;

Start

// initialize the room names, and price for each room

// array index starts from 0 and goes to n-1 where n is the total number of elements in the array

roomNames[0] = "Single";

roomNames[1] = "Single Deluxe";

roomNames[2] = "Double";

roomNames[3] = "Double Deluxe";

roomPrice[0] = 79.95;

roomPrice[1] = 99.95;

roomPrice[2] = 149.95;

roomPrice[3] = 179.95;

// initialize each room count to 0 at the start

for(i=0;i<4;i++)

do

roomCount[i] = 0;

end for

// input the room type, user should type exit to indicate they are done

Display "Enter room type ('exit' to quit ) : ";

Input roomInput;

// loop that continues till user types quit

while(roomInput != "quit")

do

roomFound = false;

// loop to determine if user input is valid and increment the associated room count

for(i=0;i<4;i++)

do

if(roomNames[i] == roomInput) then

roomCount[i] = roomCount[i] + 1;

roomFound = true;

end if

end for

// if invalid room type, display error

if(roomFound == false) then

Display "Invalid input for Room type. Room type can be Single or Single Deluxe or Double or Double Deluxe ";

end if

Display "Enter room type ('exit' to quit ) : ";

Input roomInput;

end while

// set totalRevenue and totalRoomsNeeded to 0

totalRevenue = 0;

totalRoomsNeeded = 0;

Display("Room Type Price($) Rooms Needed");

// loop to display each room type details and calculate the totalRevenue and totalRoomsNeeded

for(i=0;i<4;i++)

do

Display(roomNames[i],roomPrice[i],roomCount[i])

totalRevenue = totalRevenue + (roomPrice[i]*roomCount[i]);

totalRoomsNeeded = totalRoomsNeeded + roomCount[i];

end for

// calculate average revenue

if(totalRoomsNeeded > 0) then

avgRevenue = totalRevenue/totalRoomsNeeded;

else

avgRevenue = 0;

end if

// display the total revenue and average revenue

Display("Total revenue from all rooms : $",totalRevenue);

Display("Average revenue from a room : $",avgRevenue);

End

//end of pseudocode

User Hiral
by
4.6k points