How many floors does the hotel have - how many occupied


Hotel Occupancy A hotel's occupancy rate is calculated as follows:

Occupancy rate = number of rooms occupied div ÷ total number of rooms 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 that 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. Sample run: How many floors does the hotel have?

5 How many rooms does floor 1 have? 20 How many occupied rooms does floor 1 have? 10 How many rooms does floor 2 have?

10 How many occupied rooms does floor 2 have?

5 How many rooms does floor 3 have?

12 How many occupied rooms does floor 3 have? 13 Invalid.

Must be 12 or less. Re-enter: 10 How many rooms does floor 4 have? 10 How many occupied rooms does floor 4 have? 5 How many rooms does floor 5 have? 10 How many occupied rooms does floor 5 have? 2 Number of rooms: 62 Occupied rooms: 32 Vacant rooms: 30 Occupancy rate: 0.5161290322580645

Solution Preview :

Prepared by a verified Expert
JAVA Programming: How many floors does the hotel have - how many occupied
Reference No:- TGS02386318

Now Priced at $15 (50% Discount)

Recommended (96%)

Rated (4.8/5)