I have a program for school that I've started and it is very close to working but for some reason the calculation for the occupancy percentage isn't working (Line 34). Any help is appreciated.
#include<iostream>
usingnamespace std;
int main()
{
int floors=0, rooms=0, totalrooms=0, totaloccupied=0, occupied=0, count=0;
int pctoccupied;
cout << "How many floors does the hotel have? ";
cin >> floors;
while (count < floors)
{
count++;
cout << "\nHow many rooms on floor " << count << "? " ;
cin >> rooms;
cout << "\nHow many of those rooms are currently occupied? ";
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;
}
totaloccupied += occupied;
totalrooms += rooms;
}
pctoccupied = (totaloccupied / totalrooms) * 100;
cout << "The total amount of rooms is " << totalrooms << ".\n";
cout << totaloccupied << " rooms are occupied.\n";
cout << totalrooms - totaloccupied << " rooms are unoccupied.\n";
cout << pctoccupied << " percent of the rooms are occupied.\n" << endl;
return 0;
}
Thanks again for the help! The math works now but I have another issue now that I've read the problem. It seems that the floors should be already defined and only the floors 10-12 & 14-16 should be calculated (because of the hotel NOT having a 13th floor) and I've been able to adjust the code to do that but I have not been able to figure out how to skip 13 and go to 14. This is my attempt but it isn't working as it starts on the 14th floor instead of the 10th.