Make a program that calculates the occupancy rate for a


Hotel Occupancy

Make a program that calculates the occupancy rate for a hotel. The program should begin by prompting the user for the number of floors in the hotel. Use the following prompt:

Number of floors:

Input Validation: Do not accept a value less than 1 or greater than 20 for the number of floors.

A loop should then iterate once for each floor. For each iteration, the user should be prompted for the number of rooms on the floor and how many of them are occupied.

It is traditional that many hotels do not have a fourth and/or thirteenth floor so

don't allow for a 4th or 13th floor.

Use the following prompt:

Number of rooms on floor x: (x represents the floor number)

Number of occupied rooms:

Input Validation: Do not accept a value of less than 1 or more than 10 for the number of rooms on a floor. Also, ensure the number of occupied rooms does not exceed the total number of rooms on a particular floor.

The program should display the total number of rooms in the hotel, how many are occupied, how many are unoccupied, and the percentage of rooms that are occupied ( ie. occupancy rate).

Use the following format for your output:

Total number of rooms: xxx

Number of occupied rooms: xxx

Number of unoccupied rooms: xxx

Occupancy rate: xxx.x%

Note: You must use both 'while' and 'for' loop structures in your solution.

The user should be allowed to process as many "hotels" as needed without having to re-execute the program.

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: Make a program that calculates the occupancy rate for a
Reference No:- TGS02574531

Now Priced at $10 (50% Discount)

Recommended (99%)

Rated (4.3/5)