
Respuesta :
Answer:
Check the explanation
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