48.0k views
3 votes
*You are required to describe the following characteristics: purpose, input, process, and output, and create three test cases, pseudocode and a flowchart for each of the following questions.**

Write a program that calculates the occupancy rate for a hotel. The program should start by asking the user how many floors the hotel has. A loop should then iterate once for each floor. In each iteration, the loop should ask the user for the number of rooms on the floor and how many of them are occupied. After all the iterations, the program should display how many rooms the hotel has, how many of them are occupied, how many are unoccupied, and the percentage of rooms that are occupied. The percentage may be calculated by dividing the number of rooms occupied by the number of rooms.

NOTE: It is traditional that most hotels do not have a thirteenth floor. The loop in this program should skip the entire thirteenth iteration.

Input Validation: Do not accept a value less than 1 for the number of floors. Do not accept a number less than 10 for the number of rooms on a floor.

User Bronts
by
7.7k points

1 Answer

1 vote

Final answer:

Purpose: To calculate the occupancy rate for a hotel based on user input about the number of floors, rooms per floor, and their occupancy status.

Input: Number of floors in the hotel, number of rooms per floor, number of occupied rooms per floor.

Process: Loop through each floor, collecting information about the rooms and their occupancy status.

Output: Total rooms in the hotel, occupied rooms, unoccupied rooms, and the percentage of occupied rooms.

Step-by-step explanation:

Here's an overview of the characteristics (purpose, input, process, output), three test cases, pseudocode, and a flowchart for the program to calculate the occupancy rate for a hotel:

Characteristics:

Purpose: To calculate the occupancy rate for a hotel based on user input about the number of floors, rooms per floor, and their occupancy status.

Input: Number of floors in the hotel, number of rooms per floor, number of occupied rooms per floor.

Process: Loop through each floor, collecting information about the rooms and their occupancy status.

Output: Total rooms in the hotel, occupied rooms, unoccupied rooms, and the percentage of occupied rooms.

Test Cases:

Test Case 1:

Number of floors: 5

Rooms per floor: 15, 20, 25, 30, 35

Occupied rooms: 10, 15, 20, 25, 30

Test Case 2:

Number of floors: 8

Rooms per floor: 12, 18, 24, 30, 22, 28, 16, 20

Occupied rooms: 6, 9, 12, 15, 11, 14, 8, 10

Test Case 3:

Number of floors: 15

Rooms per floor: 25 for all floors

Occupied rooms: 20 for all floors

Pseudocode:

Start

Initialize variables: totalRooms = 0, totalOccupiedRooms = 0

Ask user for the number of floors

While loop for each floor (1 to number of floors)

Skip if floor number is 13

Ask user for the number of rooms on the floor

Validate rooms per floor (should be >= 10)

Ask user for the number of occupied rooms on the floor

Validate occupied rooms (should be <= rooms per floor)

Add rooms per floor to totalRooms

Add occupied rooms to totalOccupiedRooms

End loop

Calculate unoccupied rooms = totalRooms - totalOccupiedRooms

Calculate occupancy rate = (totalOccupiedRooms / totalRooms) * 100

Display totalRooms, totalOccupiedRooms, unoccupied rooms, occupancy rate

End

User Dredok
by
7.4k points