Hi, I am trying to calculate how many rooms a hotel has, how many are occupied, and the percentage of rooms that are occupied. It is suppose to do this after a loop iterates once for each floor while skipping the 13th floor. I am new to this, any suggestions?
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
//Declare variables
int numFloors = 0;
int occupiedRooms = 0;
double perRoomOccupied = 0;
int unoccupiedRooms = 0;
int roomCount = 1;
int totalUnoccupied = 0;
int numRooms = 0;
cout << "How many floors does the hotel have?" << endl;
cin >> numFloors;
cout << "How many rooms are there on each floor" << endl;
cin >> numRooms;
cout << "How many of the rooms are occupied?" << endl;
cin >> occupiedRooms;
while(numFloors < 0)
{
cout << "Number of floors must be at least one. Please re-renter" << endl;
cin >> numFloors;
}
while(numRooms < 10)
{
cout << "Number of rooms per floor must be at least 10. Please re-renter" << endl;
cin >> numRooms;
}
while(roomCount <= numFloors)
{
totalUnoccupied = totalRooms - totalOccupied;
perRoomOccupied = occupiedRooms / totalRooms;
totalOccupied += occupiedRooms;
totalRooms += numRooms;
cout << "The hotel has" << totalRooms << endl;
cout << occupiedRooms << "of the rooms are occupied" << endl;
cout << unoccupiedRooms << " of the rooms are unoccupied" << endl;
cout << perRoomOccupied << "%" << "of the rooms are occupied" << endl;
roomCount++;
}
return 0;
}