C++ program

profileSari7700
04hotel.pdf

1

CS150 Assignment 5 Hotel Occupancy Summarizer

Date assigned: Monday, October 19, 2015

Program due: Wednesday, October 28, 2015, 1pm (35 points)

You have just been hired by the Swynn Hotel in Las Vegas to help them determine their

occupancy rate. The manager at Swynn would like you to print out a report that shows for

each floor, the number of rooms on the floor, the number of occupied rooms, and the

number of unoccupied rooms. The report must also list the total number of rooms, the

total number of occupied rooms, and the total number of unoccupied rooms. Finally, the

report must display the percentage of occupied rooms and the percentage of unoccupied

rooms.

The data that has been provided for you is in a text file named “hotel.txt” and includes a

series of lines of data. The first line contains the number of floors in the hotel. This is

followed by a line for each floor in the hotel containing the number of rooms, then a

series of zeros or ones indicating if each room is occupied (one) or unoccupied (zero).

For example, if a hotel has two floors, floor 1 has 5 rooms, 3 of which are occupied, and

floor 2 has 3 rooms, none of which are occupied, then the file would look like:

2 5 0 0 1 1 1 3 0 0 0

The hotel manager also wants your program to account for the fact that there is no 13th

floor at the Swynn. Most hotels do not have a 13th floor as the number 13 is considered

unlucky. Triskaidekaphobia is the fear of the number 13! Instead of a 13th floor, the

Swynn goes straight from the 12th floor to the 14th floor.

Notes:

1. Read the hotel data from a file called “hotel.txt”. 2. Minimally, a data file must consist of one line containing the number zero

indicating that there are no floors in this hotel.

3. There is no input from the user in this program. All the data will be read from the input file.

2

For the following input file:

14 3 0 1 1 6 0 0 0 1 1 1 2 1 1 7 0 1 0 0 1 1 1 4 0 0 0 1 8 0 0 0 1 1 0 1 0 3 0 0 0 1 0 8 0 0 1 1 0 0 1 1 2 0 1 5 1 0 1 0 1 4 1 1 1 0 3 1 1 1 6 1 1 1 1 1 1

Your program must produce the following output exactly:

*******************

* Hotel Occupancy *

*******************

Floor Rooms Occupied Unoccupied

-------------------------------------

1 3 2 1

2 6 3 3

3 2 2 0

4 7 4 3

5 4 1 3

6 8 3 5

7 3 0 3

8 1 0 1

9 8 4 4

10 2 1 1

11 5 3 2

12 4 3 1

14 3 3 0

15 6 6 0

-------------------------------------

Total 62 35 27

Percentage of occupied rooms: 56.45%

Percentage of unoccupied rooms: 43.55%

3

To complete this assignment you must submit the following:

1. An electronic copy of your program on Turing

a. Add a new project named 05_Hotel to your previously created assignment solution called PUNetIDAssignments. It is vital that you name your project

correctly!

b. Type your program (fully documented/commented) into the project. You must follow the coding standards!

c. Pay attention to the example output! Your program’s output must look exactly like the example output! The spacing and newlines in your output

must match exactly.

d. Make sure that your program compiles and runs correctly. If you get any errors, double check that you typed everything correctly.

e. Make sure that your program does not produce any warnings.

f. Once you are sure that the program works correctly it is time to submit your program. You do this by logging on to Grace and placing your complete

solution folder in the CS150-01 Drop folder. This solution folder must also

contain your four previous projects.

g. The program must be in the drop folder by 1pm on the day that it is due. Anything submitted after that will be considered late.

2. A hard copy of your program

a. The hard copy must be placed on the instructor’s desk by 1pm on the day that it is due.

b. The hard copy must be printed in color, double-sided, and stapled if necessary. Staple the program output described above to your program.

c. Your tab size must be set to 2 and you must not go past column 80 in your output.

Good luck! And remember, if you have any problems, come and see

straight away. 