Topical Information

This program will provide you the chance to show your mastery of functions and decision making — and perhaps a bit of modulo! (Of course, you'll continue to make elegant use of character input's amazing properties.) There are also options for making a library and using repetition.

Program Information

During the first few weeks of the semester (ANY semester), students are so lost that simple reasoning flies out the window. Between 5 and 10 people a day come to most teachers and staff and ask: "Where's H131?". Unfortunately, most of them are on the second floor when they ask this...*sigh*

Administration has commissioned an automatic service which we are to prototype (HA! And you thought we'd just made up that word! *phbbt*). The user will enter their room and the system will tell them which floor it is on. (Future versions will also allow the system to tell the user to head left, right, etc. ...or perhaps to simply turn around.)

You'll need to read rooms of the form 'H131' and print output such as "That's on the 1st floor of the H building!" (Just to make things easier, we'll assume that all floors can have at most 100 rooms numbered 00 to 99 — this seems fairly standard, anyway.)

Use separate functions to:

  1. read their building and room number (one function; two results; no 'inputs')

  2. determine the floor (one result; one input)

  3. determine the suffix characters/string (st, nd, rd, or th) for the floor (one input; one or two results)


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

$ ./floor.out

                 Welcome to the Floor Determining Program!!!

Which room are you looking for?  d221

Thank you!!  Calculating...  Done.

Your room is on the 2nd floor of the D building.


Do you have another class/office to find?  y


Which room are you looking for?  J109

Thank you!!  Calculating...  Done.

Your room is on the 1st floor of the J building.


Do you have another class/office to find?  Y

Which room are you looking for?  n390

Thank you!!  Calculating...  Done.

Your room is on the 3rd floor of the N building.


Do you have another class/office to find?  n

Thank you for using the FDP!!

Endeavor to have a localized day...

$

Important Questions

  1. How do you separate the user's building letter from their actual room number? (Hint: How did you read die-rolls or times of day or even initials with periods?)

  2. How can you allow the user to enter either upper or lowercase letters for the yes/no question?! (It's amazing!)

  3. How can you decide which floor their room is on from the room number?

  4. Given a value like 4 or 11 or 23, how can you tell what suffix to print (st, nd, rd, or th)? Is there a pattern?

  5.     0th   1st   2nd   3rd   4th   5th   6th   7th   8th   9th
       10th  11th  12th  13th  14th  15th  16th  17th  18th  19th
       20th  21st  22nd  23rd  24th  25th  26th  27th  28th  29th
       30th  31st  32nd  33rd  34th  35th  ...
       .
       .
       .
      100th 101st 102nd 103rd 104th 105th  ...
      110th 111th 112th 113th 114th 115th  ...
      120th 121st 122nd 123rd 124th 125th  ...
       .
       .
       .
    

    *ponder* Hmm...

  6. How can a function input a number (note: function input!) and 'return' as output 2 letters!? A char can store only a single value at a time and the return value can only be one thing. How can we possibly do this? (Hint: There are two ways...)

This assignment is (Level 4).

Options


Total Level Possible

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