Question: Can someone turn this code into a flow chart? This is the exercise: Write a program that calculates the occupancy rate for a hotel. The

Can someone turn this code into a flow chart?

This is the exercise: Write a program that 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. After all the iterations, the program should display how many rooms the hotel has, how many of them are occupied, how many are unoccupied, and the percentage of rooms that are occupied. The percentage may be calculated by dividing the number of rooms occupied by the number of rooms.

#include

using namespace std;

int main()

{

float occupancy_rate = 0,

rooms_occupied = 0,

total_rooms = 0;

int num_of_rooms,

num_of_floors,

total_rooms_used = 0,

total_rooms_occupied = 0,

total_rooms_unoccupied = 0;

cout << "How many floors does your hotel have? ";

while (!(cin >> num_of_floors) || (num_of_floors < 1))

{

cout << "ERROR: number of floors must be "

<< "greater that 1 ";

cin.clear();

cin.ignore(1230, ' ');

}

for(int i = 0; i < num_of_floors; i++)

{

if ((i + 1) == 13)

{

cout << " Skipping 13th floor."

<< endl

<< endl;

}

else

{

cout << "How many rooms does floor number ";

cout << (i + 1) << " have? ";

while (!(cin >> num_of_rooms) ||

(num_of_rooms < 10))

{

cout << "ERROR: enter a number "

<< "greater than 10: ";

cin.clear();

cin.ignore(123, ' ');

}

total_rooms += num_of_rooms;

cout << "How many rooms are occupied "

<< "on that floor? ";

while (!(cin >> rooms_occupied) ||

(rooms_occupied < 1))

{

cout << "ERROR: enter a number "

<< "greater than 10: ";

cin.clear();

cin.ignore(123, ' ');

}

total_rooms_used += rooms_occupied;

}

}

total_rooms_unoccupied = total_rooms - total_rooms_used;

cout << "Total rooms unoccupied = "

<< total_rooms_unoccupied

<< endl;

cout << "Total rooms used = "

<< total_rooms_used

<< endl;

cout << "Total number of rooms = "

<< total_rooms

<< endl;

occupancy_rate = (total_rooms_used / total_rooms) * 100;

cout << "Occupancy rate = "

<< occupancy_rate

<< "%."

<< endl;

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!