basic c++ help

Write a program that calculates the occupancy rate for a hotel.

Calculates the occupancy rate for a hotel. The program should start by asking the user how many floors the hotel has. A loop should then iterate once for each floor. In each iteration, the loop should ask the user for the number of rooms on the floor and how many of them are occupied.




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

	int floors, rooms, totalrooms, totaloccupied, occupied, count;
	count = 0;
	
	cout << "How many floors does the hotel have?\n";
	cin >> floors;
	
for (; count <=floors; count++)		{
		
		cout << "How many rooms on floor " << count << "?\n";
		cin >> rooms;
		cout << "How many of those rooms are currently occupied?\n";
		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;
				}	 



I'm stuck here. How do I to output these info based on the user input:


1) The total number of rooms on each floor. (example : floor 1, total rooms 30
floor 2, total rooms 20) etc. etc

2) The number of rooms currently occupied on each floor.

3) The number of rooms currently unoccupied on each floor.

4) The floor’s occupancy rate (Number of rooms currently occupied divided by the total number of rooms)

Last edited on
1
2
3
4
{
		cout << "There are " << floors*count << "total rooms.\n";
		cout  " << occupied << " Rooms are are occupied?\n";
} 
how would i output the data that the user entered, Samuel? If they entered 2 floors.

How would I output for example : floor 1, total rooms: 30
floor 2, total rooms: 20
Last edited on
Topic archived. No new replies allowed.