123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
#include <iostream> using namespace std; int main() { float occ_rate = 0, rooms_occupied = 0, total_rooms = 0; int rooms, num_floors, filled_rooms = 0, total_occupied = 0, unoccupied = 0; cout << "Floors in the hotel: "; while (!(cin >> num_floors) || (num_floors < 1)) { cout << "Enter a valid number of floors"; } for(int i = 0; i < num_floors; i++) { { cout << "Rooms on floor "; cout << (i + 1)<<": "; while (!(cin >> rooms)) total_rooms += rooms; cout << "Rooms occupied: "; while (!(cin >> rooms_occupied) || (rooms_occupied < 1)) filled_rooms += rooms_occupied; } } unoccupied = total_rooms - filled_rooms; cout << "Total rooms unoccupied = " << unoccupied << endl; cout << "Total rooms used = " << filled_rooms << endl; cout << "Total number of rooms = " << total_rooms << endl; occ_rate = (filled_rooms / total_rooms) * 100; cout << "Occupancy rate = " << occ_rate << "%." << endl; return 0; }