Levels Tought:
Elementary,Middle School,High School,College,University,PHD
Teaching Since: | Apr 2017 |
Last Sign in: | 12 Weeks Ago, 1 Day Ago |
Questions Answered: | 4870 |
Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
 HI pls help me with this Java HWÂ
Hotel Occupancy
A hotel’s occupancy rate is calculated as follows:
Occupancy rate = number of rooms occupied ÷ 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? 5How many rooms does floor 1 have? 20How many occupied rooms does floor 1 have? 10How many rooms does floor 2 have? 10How many occupied rooms does floor 2 have? 5How many rooms does floor 3 have? 12How many occupied rooms does floor 3 have? 13Invalid. Must be 12 or less. Re-enter: 10How many rooms does floor 4 have? 10How many occupied rooms does floor 4 have? 5How many rooms does floor 5 have? 10How many occupied rooms does floor 5 have? 2Number of rooms: 62Occupied rooms: 32Vacant rooms: 30Occupancy rate: 0.5161290322580645