//Programmer: Bo Bayles  Date: 21 September 2004
//File: lab5.cpp         Class: CS54 C
//Purpose: This program gets user input to determine how many times
//  to go through a loop, to determine what percentage of rooms are
//  occupied in a hotel.

#include <iostream>
using namespace std;

int main()
{
  int iFloors = 0, iCounter = 1, iRooms = 0, iOcc = 0;
  float fTotalRooms = 0, fTotalOcc = 0;
  //fTotalRooms and fTotalOcc are floats so when dividing I don't get 1.

  cout << "This program will calculate the percentage of rooms that "
       << "are occupied" << endl << " in your hotel." << endl;

  cout << "\n Enter the number of floors: ";
  cin >> iFloors;

  while (iCounter <= iFloors)
  {
    cout << "\n Enter the number of rooms on floor " << iCounter << " : ";
    cin >> iRooms;

    fTotalRooms = fTotalRooms + iRooms;

    cout << " Enter the number of occupied rooms on floor " << iCounter
         << " : ";
    cin >> iOcc;

    fTotalOcc = fTotalOcc + iOcc;

    iCounter++;
  }
  //Increment iCounter until it is equal to the number of floors. Ask for
  //  number of rooms and number occupied, and keep a running total of both.

  cout << "\n Number of floors: " << iFloors << endl
       << " Total number of rooms: " << fTotalRooms << endl
       << " Total number of rooms occupied: " << fTotalOcc << endl
       << "\n Percent of rooms occupied: " << ((fTotalOcc / fTotalRooms) * 100)
       << "%" << endl;
  //Divide the total occupied by the total number of rooms and multiply by 100
  //to get a percentage.

  cout << "\n Exiting..." << endl;

  return 0;
}

