Write a program that calculates the occupancy rate for a hotel.
Calculates the occupancy rate for a hotel. The program should start by asking the user how many floors the hotel has. A loop should then iterate once for each floor. In each iteration, the loop should ask the user for the number of rooms on the floor and how many of them are occupied.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
int floors, rooms, totalrooms, totaloccupied, occupied, count;
count = 0;
cout << "How many floors does the hotel have?\n";
cin >> floors;
for (; count <=floors; count++) {
cout << "How many rooms on floor " << count << "?\n";
cin >> rooms;
cout << "How many of those rooms are currently occupied?\n";
cin >> occupied;
if (occupied > rooms)
{
cout << "The rooms occupied cannot exceed the number of rooms.\n";
cout << "How many rooms on floor " << count << " are occupied?\n";
cin >> occupied;
}
I'm stuck here. How do I to output these info based on the user input:
1) The total number of rooms on each floor. (example : floor 1, total rooms 30
floor 2, total rooms 20) etc. etc
2) The number of rooms currently occupied on each floor.
3) The number of rooms currently unoccupied on each floor.
4) The floor’s occupancy rate (Number of rooms currently occupied divided by the total number of rooms)