View Single Post
Old 09-28-2005, 09:11 PM   #6 (permalink)
subodhgupta1
Registered User
 
Join Date: Sep 2005
Posts: 24
subodhgupta1 is on a distinguished road
Post Hotel Occupancy

Hotel Occupancy
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.
NOTE: It is traditional that most hotels do not have a thirteenth floor. The loop in this program should skip the entire thirteenth iteration.

Input Validation: Do not accept a value less than one for the number of floors. Do not accept a number less than 10 for the number of rooms on a floor.

This is what I tried and seem to go nowhere
Code:
//---------------------------------------------------------------------------
#include <iostream.h>
#include <iomanip>
#include <cstring>
#include <fstream>
#include <utility>
#include <conio.h>
using namespace std;
//---------------------------------------------------------------------------
int main (void)
{
  // Assuming Varibles
   int no_of_floors;
   int no_of_rooms;
   int no_of_occupied_rooms;
   //int total_no._of_rooms;
   //int total_no._of_occupied_rooms;
   //int total_no._of_unoccupied_rooms;
   //double percentage_of_occupied_rooms;

  	// Asking for inputs.
   cout << "Please enter no. of floors in the building: ";
	cin >> no_of_floors;
   //cout << "Please enter the distance: ";
	//cin >> distance;

   	// Calculating the look
   if (no_of_floors > 0)
   {
        //int floor=1;
        while (no_of_floors <= no_of_floors)
        {
          cout << "Please enter no. rooms in the floor: ";
          cin>> no_of_rooms;
           cout << "Please enter no. occupied rooms in the floor: ";
          cin>> no_of_occupied_rooms;
        }
        ++no_of_floors;
        no_of_rooms = no_of_rooms + no_of_rooms ;
        no_of_occupied_rooms = no_of_occupied_rooms + no_of_occupied_rooms;

   }

   // calculating


	// Displaying the result.
   cout << "Total no. rooms in the floor: " << no_of_rooms << endl;
   cout << "Total no. rooms in the floor: " << no_of_occupied_rooms << endl;
   cout << endl << endl << endl << "Press Any Key to Continue...";
    getch ();
    return 0;
    }

Last edited by redhead; 09-29-2005 at 02:43 AM.
subodhgupta1 is offline   Reply With Quote