Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Handbook Of Relational Database Design

Authors: Candace C. Fleming, Barbara Von Halle

1st Edition

0201114348, 978-0201114348

More Books

Students also viewed these Databases questions

Question

2. What are quantitative and qualitative methods of forecasting?

Answered: 1 week ago

Question

5. Understand how cultural values influence conflict behavior.

Answered: 1 week ago

Question

8. Explain the relationship between communication and context.

Answered: 1 week ago