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
Answer for 3 and 4 please
Nata [24]

Answer:

3. D: px

4. B: web page

Explanation:

All font sizes are measured in px unless specified otherwise (in em's for example).

The correct answer is a web page because itself is a unique file that displays multimedia components.

3 0
3 years ago
Read 2 more answers
Microsoft Word is ________________ software.
s2008m [1.1K]

Answer:

Application

Explanation:

Word is used to change things and make things

4 0
3 years ago
For which product would the producer keep a high profit margin and offer after-sales service?
Zina [86]

What are the products?

6 0
4 years ago
Please help me with this
olasank [31]

Answer:

restart the computer! if that doesnt work, try going to audio settings and looking around for anything out of place.

Explanation:

8 0
3 years ago
1-5. Discuss briefly the function and benefits of computer network. (5pts​
Elden [556K]

Computer networks allow an unlimited amount of computers to communicate with each other. This is especially useful in enterprise environments, as technicians have to deal with hundreds of computers at a time. Computer networks make it easier to share files, increase storage capacity, better communication, easier to to control computers remotely, easier to share resources, ability to share a single internet connection on multiple devices. Computer networks also have a lot of cost benifits too, as network administration is centralised, meaning that less IT support is required, and you can cut costs on sharing peripherals and internet access.

Hopefully this helps you out!

7 0
3 years ago
Other questions:
  • In your opinion, what is the best practice for organizing files within your computer?
    15·2 answers
  • Are video games considered information technology
    9·2 answers
  • What are the disadvantages of cloud computing?
    9·1 answer
  • This is the formula for the future worth of an investment over time with consistent additional monthly payments and a steady rat
    10·1 answer
  • When you need to move data over long distances using the internet, for instance across countries or continents to your amazon s3
    5·2 answers
  • What are the biggest problems facing the criminal justice system in the area of computer crime
    10·2 answers
  • Sixteen stations, numbered 1 through 16, are contending for the use of a shared channel by using the adaptive tree walk protocol
    7·1 answer
  • Which key combination should you use
    9·2 answers
  • Which insert image option allows a user to insert images from the internet?
    5·2 answers
  • Select the correct answer.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!