Alright, I'm having a lot of trouble grasping what's going on in my Computer Science class...
Trust me when I say that you guys don't wanna see what I have so far...
The first step is to break this problem down. What is it asking? Right off the bat, the problem asks for a loop - one for each floor, for the number of floors the user inputs. You'll need to define an integer variable to store the number of floors - call it
numFloors. Then output a message asking the user for the input (i.e. "How many floors will your hotel have?") and prompt the user to input
numFloors. If the user enters less than 1 floor, prompt them for different input (using a while(...) loop will do this).
You will also need two additional integer variables - one to store the total rooms, and one to store the total occupied rooms (Call them
numRooms and
numOccRooms, respectively). Initialize both variables to 0.
Next is the first loop. You'll want to loop an index (
i) from 1 to
numFloors, inclusive. A
for loop will work marvelously. But here's our first problem:
Hotels skip the 13th floor, according to your problem specification. I can think of 2 ways to interpret this:
Suppose the user wants less than 13 floors. No problem.
Suppose the user wants exactly 13 floors. There are 2 possibilities. (1) Your teacher wants you to have a total of 13 floors, and treat the 13th floor as the 14th (a.k.a. after 12 iterations, start outputting
i+1 for the floor number instead of
i). Or, (2) Your teacher wants to completely ignore the 13th iteration - thus, if the user specifies 13 floors, there will actually be only 12 floors. You should ask for clarification on this issue.
Now that you have the loop header, you should begin executions for floor analysis (a.k.a. find out how many rooms there are and how many are occupied). I'll leave these simple calculations to you - most of this is simply prompting the user for input and storing user input into a temporary value. You'll also have to check if the rooms for this floor are greater than 10; if not, prompt the user for new input. Finally, you'll have to check if the number of occupied rooms exceeds the number of rooms; if not, prompt the user for new input.
After the loop has finished, you'll need to output relevant data; number of rooms, number of occupied rooms, number of unoccupied rooms, and the percentage of occupied rooms. All of this is straightforward except for the percentage. If you simply divide
numOccRooms by
numRooms, you'll get an integer - but you need a decimal number, such as 93.2%. In order to do this, you will need to cast one or both of the integer values to a double using a
static_cast<double>(...) call.
Hopefully, this will give you a basic shell so that you can start programming. Good luck!