1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
dedylja [7]
3 years ago
10

Write a program that calculates the occupancy rate for each floor of a hotel. The program should start by asking for the number

of floors the hotel has. A loop should then iterate once for each floor. During 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 the number of rooms the hotel has, the number that are occupied, the number that are vacant, and the occupancy rate for the hotel. 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.
Computers and Technology
1 answer:
pickupchik [31]3 years ago
6 0

Answer:

# User is prompted to enter the number of floor in hotel

# The received value is assigned to no_of_floor

no_of_floor = int(input("Enter the number of floor in the hotel."))

# This loop is to enforce that user input is not less than 1

while (no_of_floor < 1):

   no_of_floor = int(input("Enter the number of floor in the hotel."))

# counter variable is initialized to loop through the no_of_floor

counter = 1

# total number of rooms occupied in the hotel is initialized to 0

total_occupied = 0

# total number of rooms vacant in the hotel is initialized to 0

total_vacant = 0

# total number of rooms in the hotel is initialized to 0

total_room = 0

# loop through each floor

while counter <= no_of_floor:

   # number of room in a floor is received from user

   number_of_room = int(input("Enter the number of room in floor: "))

   # this loop ensure that the number must not be less than 10

   while (number_of_room < 10):

       number_of_room = int(input("Enter the number of room in floor "))

   # number of occupied room is a floor is accepted from user

   number_of_occupied = int(input("Enter the number of occupied room."))

   # this loop ensure that the no_of_occupied is less than no_of_room

   while (number_of_occupied > number_of_room):    

       number_of_occupied = int(input("Enter the number of occupied room."))

   

   # number of vacant room in a floor is calculated

   floor_vacant = number_of_room - number_of_occupied

   # total number of occupied room is calculated

   total_occupied += number_of_occupied

   # total room in the hotel is calculated

   total_room += number_of_room

   # total number of vacant room is calculated

   total_vacant += floor_vacant

   # the counter is increment to move to the next floor

   counter += 1

# occupancy_rate is calculated as a percentage

occupancy_rate = (total_occupied / total_room) * 100

# Number of total room is displayed

print("The total number of room in the hotel is: ", total_room)    

# Number of total vacant room is displayed

print("The number of vacant room in the hotel is: ", total_vacant)

# Number of total occupied room is displayed

print("The total number of occupied room in the hotel is: ", total_occupied)

# The occupancy rate for the hotel is displayed to 2 decimal

#  place percent

print("The occupancy rate for the hotel is: {:.2f}%".format(occupancy_rate))

Explanation:

The program is well commented. It put all the constraint into consideration like:

  • not allowing a user to enter less than 1 for number of floors
  • not allowing a user to enter less than 10 for number of rooms in a floor
  • not allowing a user to enter number of occupied room greater than number of room in a floor.
You might be interested in
Help me with this please, it is for tech
Sonbull [250]
I believe it’s dsl.
5 0
4 years ago
A man travel 200m towards east&lt;br /&gt;from his house then takes left&lt;br /&gt;to turn and moves 200 m north&lt;br /&gt;fin
11Alexandr11 [23.1K]
Using the Pythagorean theorem:

200^2 + 200^2 = x^2

x = 282.842712... from the original distance
4 0
4 years ago
How do you play game on phone<br>​
ser-zykov [4K]
You download a game from the App Store
5 0
3 years ago
Read 2 more answers
Match each word to its correct meaning.
Juli2301 [7.4K]

Answer:

1. Computer Network - a group of computers that are  Interconnected in order to share  Information or documents  the component in the body of the  computer that stores all of your files and  folders

2. CPU - the central processing unit or part  Inside the body of the computer that  enables the computer to function, sometimes referred to as the brain of the  computer

3. Hard Drive - The componet in the body of the computer that stores all of your files and folders

4. Hardware - Physical parts of the computer or technical equipment

5. Internet - Interconnected computer networks throughout the world that everyone can use

6. Laptop - A small mobile computer

7. Motherboard - The main board in the body of the computer that contains chips and other compnents

8. Software - A computer program or a set of instructions for the hardware to perform

8 0
3 years ago
Over time, attackers have had to increase their skills to be able to attack systems or create viruses. True False
PSYCHO15rus [73]

Answer:

True

Explanation:

This is true :)

<em>PLEASE DO</em><em> </em><em>MARK ME</em><em> </em><em>AS BRAINLIEST</em><em> </em><em>IF MY</em><em> </em><em>ANSWER IS</em><em> </em><em>HELPFUL</em><em> </em><em>;</em><em>)</em><em> </em>

3 0
4 years ago
Other questions:
  • If you delete a view, account administrators can recover the view using the "trash can" function within how many days?
    7·2 answers
  • The reason why a database table is in the first normal form (1NF), but not in the second form (2NF) is because:
    12·1 answer
  • As a safe driver, you cannot, __________
    13·1 answer
  • Give one example of a civil engineering structure.
    5·1 answer
  • When you first launch the internet, what page will open?
    9·1 answer
  • A lead views a specific page on your website, say, your case study page. You then send targeted follow-up content like one of yo
    14·1 answer
  • The Internet raises the bargaining power of customers most effectively by: making information available to everyone. reducing ba
    15·1 answer
  • The ability to adapt to increases or decreases in demand for processing or data storage is known as ________. Group of answer ch
    9·2 answers
  • Access control lists (ACLs) are used to permit and deny traffic in an IP router.
    14·1 answer
  • How to Calculate the area of a rectangle in python
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!