Question
I need help with coding. I created a program, but instead of having it count floors backwards, I want it to count floors starting from
I need help with coding. I created a program, but instead of having it count floors backwards, I want it to count floors starting from 1. The code is below:
#include
#include
using namespace std;
int main ()
{
const int PERCENTAGE = 100, MISSING_FLOOR = 1;
int hotelFloors = 0, rooms, occupiedRooms,
totalRooms = 0, totalOccupiedRooms = 0, totalUnoccupiedRooms = 0;
double percentageOfRoomsOccupied;
cout << "How many floors does this hotel contain? ";
cin >> hotelFloors;
if (hotelFloors >= 13)
{
hotelFloors = hotelFloors + MISSING_FLOOR;
}
while (hotelFloors <= 1)
{
cout << "You must enter a value of floors greater than 1.";
cin >> hotelFloors;
}
for (int floorCount = 1; floorCount <= hotelFloors; hotelFloors--)
{
if(hotelFloors == 13)
--hotelFloors;
cout << "What is the number of rooms on floor " << hotelFloors << ":" << endl;
cin >> rooms;
while (rooms < 10)
{
cout << "A hotel floor must have atleast 10 rooms. Please try again. ";
cin.clear();
cin >> rooms;
}
cout << "How many of these rooms are occupied? ";
cin >> occupiedRooms;
while (occupiedRooms < 0 || occupiedRooms > rooms)
{
cout << "Invalid Entry. Number of rooms can't be greater than actual number of rooms or negative. Please try again" << endl;
cin.clear();
cin >> occupiedRooms;
}
totalOccupiedRooms = totalOccupiedRooms + occupiedRooms;
totalRooms = totalRooms + rooms;
totalUnoccupiedRooms = totalRooms - totalOccupiedRooms;
percentageOfRoomsOccupied = static_cast
cout << "Your hotel has " << totalRooms << " rooms "
<< totalOccupiedRooms << " of those rooms are occupied. "
<< totalUnoccupiedRooms << " of those rooms are unoccupied. "
<< "The percentage of rooms occupied: " << percentageOfRoomsOccupied << "% ";
}
}
Also, here is the link to the project:
http://algebra.sci.csueastbay.edu/~grewe/CS1160/Projects/Project5.html
It is the hotel occupancy project. Please modify the code so that output looks EXACTLY like pictured in the link. thank You.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started