Topical Information

This program will help you gain practice with branching (ifs in particular). (It might also provide you opportunities for practicing indefinite looping.)

Program Information

Write a program that determines whether the room being used for a meeting is in violation of fire law regulations regarding maximum occupancy (the most people that are allowed to be in the room — if there are too many, it becomes more difficult to get out of the room in case of a fire!).

This program will need to know the capacity rating of the room (as determined by the local fire chief and the relevant governing body) as well as the number of people that have shown up to the meeting (probably determined by a waiter or sous-chef counting heads from the kitchen doorway; *grin*).

Your program must report whether the meeting is legal or not. The meeting is legal if the number of people in attendance is less than or even equal to the maximum occupancy. The meeting is illegal whenever the number of attendees is greater than the maximum allowed attendance.

In addition to this simple declaration of legality, also provide the user with a percentage of the room that is being used (based on the maximum occupancy — not area/volume). This percentage should be rounded to the nearest whole percent.

Finally, let the user know either how many people must leave the meeting before the fire regulations will be sated or how many more people are allowed to arrive before the fire regulations will be violated.


As an example, you might have the program interaction look something like (the parts in this color are typed by the user):

$ ./roomcap.out

                 Welcome to the Room Capacity Program!!!

How many people can this room hold?  32
How many people have arrived for the meeting?  22


You've used up almost 69% of your room's capacity!

However, I pronounce this meeting LEGAL!  Proceed with the congregation!

(BTW, you have room for 10 more people...)


Thank you for using the RCP!!

Endeavor to have a tremendous day!

$

Note how the percentage here is rounded to the nearest whole percent...


Thought Provoking Questions

  1. What type of data are room capacity and meeting attendance? What type of data is a percentage?
  2. How many branches are required for your branching structure? (The answer may change depending on your choice of options to implement...)
  3. How many tests will be required to make sure your program works for all cases? (The answer may change depending on your choice of options to implement...)
  4. What was that rounding formula we talked about in lecture again? I forget, how did that work?

This assignment is (Level 2).


Option


Total Level Possible

If you did all above options, this lab could be worth as much as (Level 10.5).