CIS 254 – Data Structures Klinger
Week 1 – Homework 1
Problem:
There is a city in California that has some unique zoning laws. One of the laws includes restrictions on the number of people that can live in an apartment building. The law is dictated by some local fire code. The zoning and building laws go something like this.
Every floor in an apartment building must be laid out the same. Same number of corridors, rooms, everything.
The number of corridors allowed on a floor is equal to the number of stories in the building. For example, a four story building may have four corridors on each floor. Corridors are numbered from 1 to n on each floor.
The number of apartments on each corridor is equal to the number of corridors on the floor. If there are six corridors, each corridor may have six apartments. Apartments are numbered from 1 to n on each corridor.
The maximum number of occupants in an apartment is equal to the sum of the floor the apartment is on, plus the corridor number it is on, plus it's apartment number on the corridor. For example, an apartment on the forth floor, corridor 3, apartment 2 may have 9 residents (=4+3+2);
What the city wants you to write a program that takes the number of floors in a building as input and computes the maximum occupancy of the building. The requirements are that you: "construct" a building, "populate it", then total the occupants. You may not count the residents when you populate the building.
Deliverables:
You may copy the output of your runs and paste them in a document