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