Michael asked in TravelUnited StatesLas Vegas · 10 months ago

# C++ Hotel Room Help?

#include <iostream>

#include <iomanip>

using namespace std;

int main()

{

int roomsOnFloor = 0;

float totalRooms = 0.00;

int totalFloors = 0;

int occupiedRoomsOnFloor = 0;

float totalOccupiedRooms = 0.00;

float percentOccupied = 0.00;

cout << "Enter the number of floors: ";

cin >> totalFloors;

while (totalFloors<1)

{

cout << "Number of floors must be greater than 1. Please re enter";

cin >> totalFloors;

}

for (int i = 1); i < = totalFloors; i++)

{

if (i==13)

{

cout << "Enter the number of rooms on the floor.";

cin << roomsOnFloor;

cout << "Error: the floor number cannot be 13.";

}

else

{

cout << "Enter the number of rooms on the floor.";

cin >> roomsonFloor;

cout << "How many rooms on that floor are occupied?";

cin << occupiedRoomOnFloor;

}

}

totalrooms += roomsOnFloor;

totalOccupiedRooms += occupiedRoomsOnFloor;

percentOccupied = (totalOccupiedRooms / totalRooms * 100);

cout << "The hotel has a total of " << totalFloors << " floors." endl << endl;

cout << "The hotel has a total of " << totalRooms << " rooms." << endl << endl;

cout << "There are " << totalOccupiedRooms << " occupied rooms." << endl << endl;

cout << "There are " << totalRooms - totalOccupiedRooms << " empty rooms." << endl << endl;

cout << "The percentage of occupied rooms is " << setprecision(2) << percentOccupied << "%" << endl;

return 0;

}

Relevance
• Anonymous
10 months ago

EXCUSE ME????????

• Anonymous
10 months ago

wefewfewfewferfe

• Mark
Lv 6
10 months ago

You posted to the Las Vegas forum instead of Computers & Internet/Programming & Design

• 10 months ago

I am answering my own question because I ran out of room. I keep getting an error on the 4 statement line even though I structured it as normal. Thoughts?