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(totalOccupiedRooms)/static_cast(totalRooms) * PERCENTAGE;

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!