Question

In: Computer Science

Write a program that calculates the occupancy rate for each floor of a hotel. (Use a...

Write a program that calculates the occupancy rate for each floor of a hotel. (Use a sentinel value and please point out the sentinel in bold.) The program should start by asking for the number of floors in the hotel. A loop should then iterate once for each floor. During each iteration, the loop should ask the user for the number of rooms on the floor and the number of them that are occupied. After all the iterations, the program should display the number of rooms the hotel has, the number of them that are occupied, the number that are vacant, and the occupancy rate for the hotel. Input Validation: Do not accept a value less than 1 for the number of floors. Do not accept a number less than 10 for the number of rooms on a floor.

Solutions

Expert Solution

Answer-

Your code and output is given below as your requirement -

  • #include <iostream>
  • using namespace std;
  • int main()
  •    {  
  • cout<<"\t**********Information of Hotal that show some statistics **********\n";
  •   
  • const int numberof_FLOORS = 1;
  • const int numberof_ROOMS = 10;
  • int floors;
  • int rooms; //variable define
  • int occupied;   
  • int totalRooms=0, totalOccupied=0;
  •   
  • cout<<" Enter the number of floors,\n";
  • do{
  • cout<<"(Do not accept a number less than "<<numberof_FLOORS
  • <<")\n";
  • cout<<"Number of floors: ";
  • cin >>floors;
  • }while(floors<numberof_FLOORS); // input validation
  •   
  • cout<<"****************************************************\n";
  •   
  •   
  • for(int floor=1; floor <= floors; floor++){
  •   
  • if(floor == 13){ //// Loop over all the floors to get the data.
  • continue;
  • }
  •   
  •   
  • cout<<"Enter the number of rooms in floor \""
  • <<floor<<",\"\n"; //// Get the number of rooms in each floor,
  • do{
  • cout<<"(Do not accept a number less than "<<numberof_ROOMS
  • <<")\n";
  • cout<<"Number of rooms: ";
  • cin >>rooms;
  • }while(rooms<numberof_ROOMS);
  •   
  • totalRooms += rooms;
  •   
  • cout<<"*************************************************\n";
  •      
  • cout<<"Enter the number of occupied rooms,\n";
  • do{
  • cout<<"(Do not accept a number less than 0)\n";
  • cout<<"(it also could not be more than "<<rooms<<"\n";
  • cout<<"Number of occupied rooms: ";
  • cin >>occupied;
  • }while(occupied<0 || occupied>rooms);
  •   
  • totalOccupied += occupied;
  •   
  • cout<<"**************************************************\n";
  • }
  •   
  • // ---------------------------------------------------------
  • // Display Information of Hotal that show some statistics
  • cout<<"Display Information of Hotal that show some statistics\n";
  • cout<<" Total number of rooms: "<<totalRooms<<std::endl;
  • cout<<" Total number of occupied: "<<totalOccupied
  • <<std::endl;
  • cout<<"Total number of free ones: "
  • <<(totalRooms-totalOccupied)<<std::endl;
  • cout<<" Percentage of occupied: "
  • <<1.0*totalOccupied/totalRooms<<std::endl;
  •   
  • cout<<"********************************************************\n";
  • return 0;
  • }
  •   

Screenshot of output-

Note- Please do upvote, if any problem then comment in box sure I will help.


Related Solutions

IN JAVA Write a program that calculates the occupancy rate for each floor of a hotel....
IN JAVA Write a program that calculates the occupancy rate for each floor of a hotel. (Use a sentinel value and please point out the sentinel in bold.) The program should start by asking for the number of floors in the hotel. A loop should then iterate once for each floor. During each iteration, the loop should ask the user for the number of rooms on the floor and the number of them that are occupied. After all the iterations,...
Using Loops for the Hotel Occupancy calculator. You will write a program that calculates the occupancy...
Using Loops for the Hotel Occupancy calculator. You will write a program that calculates the occupancy of a hotel. Rules: 1# The hotel must have more than 2 floors and less than or equal 5 floors. 2# Each floor in the hotel can have a different number of rooms on the floor. 3# You must set the number of occupied rooms. Again, there must less rooms occupied than the number of rooms. 4# Using the total number of rooms and...
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.
Use JAVAProgram #1: 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 for loop should then iterate once for each floor. In each iteration of the for loop, the program should ask the user for the number of rooms of the floor and how many of them are occupied. After all of the iterations are complete the program should display how...
Write a program that calculates the floor of a decimal number as defined here. Basically the...
Write a program that calculates the floor of a decimal number as defined here. Basically the Floor of any decimal number x, is the nearest whole number less than or equal to x. ( Code Should Be In C++) Requirements 1) You must implement a function to calculate the floor (you cannot use C++'s floor function). Name it floorAndError). It will have a return value and a single parameter 2) The program will ask the user to input a number...
Please use Visual Basic Hotel Occupancy The Hotel has 8 Floors and 30 rooms on each...
Please use Visual Basic Hotel Occupancy The Hotel has 8 Floors and 30 rooms on each floor. Create an application that calculates the occupancy rate for each floor, and the overall occupancy rate for the hotel. The occupancy rate is the percentage of rooms occupied, and may be calculated by dividing the number of rooms occupied by the number of rooms. For example, if 18 rooms on the 1st floor are occupied, the Occupancy Rate is as follows: 18/30=0.6 or...
Please use Phyton to write a program: Write a program that calculates and displays the total...
Please use Phyton to write a program: Write a program that calculates and displays the total bill at a restaurant for a couple that is dining. The program should collect from the couple, cost of each meal, and the percentage of the final cost that they would like to tip. The sales tax in the state where the restaurant exists is 7.5%. Display to the user, line by line: Total Cost of Both Meals Sales Tax in dollars Tip in...
Following are the number of victories for the Blue Sox and the hotel occupancy rate for...
Following are the number of victories for the Blue Sox and the hotel occupancy rate for the past eight years. You have been asked to test three forecasting methods to see which method provides a better forecast for the Number of Blue Sox Wins. Year Number of Blue Sox Wins Occupancy Rate 1 70 78% 2 67 83 3 75 86 4 87 85 5 87 89 6 91 92 7 89 91 8 85 94 For the following, you...
Write a C++ program that calculates mileage reimbursement for a salesperson at a rate of $...
Write a C++ program that calculates mileage reimbursement for a salesperson at a rate of $ 0.35 per mile. Your program should interact with the user in this manner: MILEAGE REIMBURSEMENT CALCULATOR Enter beginning odometer reading: 13505.2 Enter ending odometer reading     : 13810.6 You traveled 305.40 miles. At $ 0.35 per mile, your reimbursement is $ 106.89. The values in red color are inputs for the program. The values in blue color are results of expressions.
Write a program that calculates the average of a four lab marks. It should use the...
Write a program that calculates the average of a four lab marks. It should use the following functions: • void getMarks() should ask the user for a lab marks, store it in a reference parameter variable, and validate it so that lab marks lower than 0 or higher than 100 is not accepted. This function should be called by main once for each of the four lab marks to be entered. • void avgGradeDisp() should calculate and display the average...
Write a C program that calculates a worker’s wages from their hours worked and hourly rate....
Write a C program that calculates a worker’s wages from their hours worked and hourly rate. This wage calculator should also account for overtime hours, calculate amount to be witheld from taxes, and calculate the final net income. Required functionality: 1. Ask the user for the number of hours worked and hourly rate in dollars. The program should be able to accept decimal values for both of these (e.g. 3.2 hours, 11.25 dollars/hour) 2. Overtime hours are those worked in...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT