#include #include using namespace std; int main() { // Decimal formatter cout << fixed << setprecision(1); // Scanner to scan the user input int floors, rooms, occupiedRooms, totalRooms = 0, totalOccupiedRooms = 0; // Do while loop do { // Prompt user to enter the amount of floors in the hotel cout << "Enter amount of floors in a hotel: "; cin >> floors; } while (floors < 1); for (int i = 1; i <= floors; i++) { do { // Prompt user to enter the amount of room on particular floor cout << "Enter the total amount of rooms on floor " << i << " (10+): "; cin >> rooms; } while (rooms < 10); // Prompt user to enter the amount of occupied room on the floor cout << "Enter the amount of occupied rooms on floor " << i << ": "; cin >> occupiedRooms; if (rooms < occupiedRooms) { cout << "Cannot have more occupied rooms than total rooms! Exiting program." << endl; return 0; } totalRooms += rooms; totalOccupiedRooms += occupiedRooms; } // Calculate total vacant int totalVacant = totalRooms - totalOccupiedRooms; double occupancyRate = 100 * (static_cast(totalOccupiedRooms) / static_cast(totalRooms)); // Print Total rooms cout << "Total rooms: " << totalRooms << endl; // Print Total occupied rooms cout << "Total occupied rooms: " << totalOccupiedRooms << endl; // Print total vacant room cout << "Vacant rooms: " << totalVacant << endl; // Print occupancy rate cout << "Occupancy rate: " << occupancyRate << "%" << endl; return 0; }