Question: Write a complete Java program with methods that prompt user for the number of floors, rooms, occupied rooms in a hotel. You must validate floors,
Write a complete Java program with methods that prompt user for the number of floors, rooms, occupied rooms in a hotel. You must validate floors, rooms, occupied rooms. Compute vacant rooms, occupancy rate on each floor and display rooms, occupied rooms, vacant rooms and occupancy rate for each floor. Use the given method names. See validation rules below:
getFloors(). This method prompts user for number of floors in a hotel and returns floors to the caller.
testFloors(floors). Do not accept a value less than 1 for the number of floors.
A loop should then iterate once for each floor. During each iteration, the loop prompts user for
getRooms(). Method prompts user for number of rooms on the floor and returns rooms.
testRooms(rooms) Do not accept a value less than 10.
getOccRooms(). Method prompts user for number of rooms that are occupied and returns occupied rooms.
testOccRooms(occRooms, rooms). Do not accept a value greater than the number of rooms on the floor.
computeVacRooms(rooms, occRooms) Calculate the number of vacant rooms on each floor and return vacant rooms.
computeOccRate(occRooms, rooms) Calculate the occupancy rate on each floor and return occupany rate. Occupancy rate = 100 * (double)rooms occupied / rooms on floor
display(rooms, occRooms, vacRooms, occRate) on each floor
You may calculate totalRooms, totalOccRooms and totalVacRooms in the hotel inside the loop.
computeHotelOccRate(totalOccRooms, totalRooms)Calculate the occupancy rate for the hotel outside the loop.
Hotel Occupancy Rate = 100 * (double)totalOccupiedRooms / totalRooms
display(totalRooms, totalOccRooms, totalVacRooms, hotelOccRate) for the hotel.
Output:
Rooms on each floor
Occupied rooms on each floor
Vacant rooms on each floor
Occupancy rate for each floor
Total number of rooms the hotel has
Total number of occupied rooms the hotel has
Total number of vacant rooms the hotel has
Occupancy rate for the hotel
Note: 1-4 inside the loop; 5-8 outside the loop
Submit this printout and the following:
An algorithm
A complete Java Program (include comments/documentation in your program)
Output (see above)
Test Data
| Floors | Rooms | Occupied |
| 1 | 10 | 8 |
| 2 | 15 | 12 |
| 3 | 20 | 25 |
Note: Invalid Occupied Rooms on floor 3. Use valid number 18 to complete your program.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
