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;

}

line 29 should be after line 21.
test for condition immediately after input..
likewise line 35 should be directly below line 23.

according to your code, ...things should be

int totalRooms = numFloors * numRooms;
int unoccupiedRooms = totalRooms - occupiedRooms;

//if you want to use a loop to calculate...
int round = 0;
int roomCount = 0;
//For room Count
for(int round = 0; round < numFloors; round++){
     if(round == 13) continue;    //skip 13th floor
     roomCount += numRooms;
}

//For occupied Count and percentage
//Implement that like above...

your question is basic but not clear...
Hope its not a homework>>>

This article has been dead for over six months. Start a new discussion instead.