The Paranoid Hotel wants to know its occupancy rate. You, being the canny comput
ID: 3923153 • Letter: T
Question
The Paranoid Hotel wants to know its occupancy rate. You, being the canny computer scientist, have promised the manager that you will write a program that computes this value. Your C++ program needs to prompt the user for the number of the floors in the hotel. Then, for each floor, you need to ask for the number of rooms on that floor and how many rooms are currently occupied on this floor. After that, you should display a report of the number of rooms in the hotel, number of occupied rooms, and the number of unoccupied rooms.
You need to remember that this is The Paranoid Hotel and that, as such, they do not have a 13th floor. Your program should skip the processing for this floor. In an even more paranoid manner, the hotel was designed so that there are never 13 rooms on a single floor and you should never allow someone to enter 13 rooms as a possibility. And, of course, you should not permit the user to enter negative numbers for any quantity.
Explanation / Answer
//C++ Program find occupancy rate of paranoid hotel.And find occupied and unoccupied rooms in hotel.
#include<stdio.h>
#include<iostream.h>
void main()
{
int numoffloors,roomsonfloor, roomsOccupied;
int available = 0, OccupiedRooms = 0, totalRooms = 0;
double occupancyRate = 0.0;
cout<<"Please enter how many floors in this hotel:-"<<" ";
cin>>numoffloors;
while(numoffloors < 1 && numoffloors>=13 )
{
cout<<"Invalid floor number, try again";
cin>>numoffloors;
}
int floorCount = 0;
for(int x = 1; x <= numoffloors; x++ )
{
floorCount++;
cout<<"Floor:" << floorCount;
cout<<"How many rooms on this floor";
cin>>roomsonfloor;
while(roomsonfloor < 7 && roomsonfloor<1)
{
cout<<"Invalid Input, 7 or greater rooms per floor";
cout<<"How many rooms on this floor";
cin>>roomsPerFloor ;
}
cout<<"Please Enter how many rooms are occupied on this floor:-";
cin>>roomsOccupied;
totalRooms += roomsonfloor;
OccupiedRooms += roomsOccupied;
available = totalRooms - OccupiedRooms;
occupancyRate =(double)OccupiedRooms/totalRooms;
}
cout<<"The Total Rooms in Hotel:- "<< totalRooms;
cout<<"The Total Rooms Occupied in Hotel:- " << OccupiedRooms;
cout<<"The Total Rooms Available in Hotel:- " <<available;
cout<<"Final Occupancy Rate Is:- "<<occupancyRate*100;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.