The goal for this week is to do more structured programming in C, using functions and pointers to organize processing and update data. In particular, you will be working extensively with strings and arrays. Before beginning, make sure you are familiar with the following string functions: strlen, strcmp, strtok, strchr, strcat, atoi. Remember you can look them up in the unix "man" pages. You may want to use others as well.
The purpose of this program is to process phone numbers by giving feedback on the type of phone number entered, and also by suggesting various character pneumonics by which to remember them.
There will be four types of phone numbers: toll-free, local land, local cell and long distance. Toll free numbers have one of these four area codes: 800, 888, 877, 866. Local phone numbers will be identified according to your home state. Use constants to store the most common land and cell (one of each) area codes in your hometown. (The examples below are for someone living in Baltimore.) All other area codes will be identified as long distance numbers.
The fun part of the program is getting suggestions on character pneumonics to use to remember the phone numbers. Look at a phone to see what characters are associated with each number button. '1' and '0' do not have any characters. Most buttons have 3 and two have 4 characters on them. Display a table which shows the 7 digit part of the entered phone number (no area code) and below each digit a column of letters that could be chosen for that digit.
In order to eliminate some pneumonic choices, remove any characters that do not appear in the name associated with the number. Redisplay the number and character options in table format. Lastly, display all the possible combinations for the number. If any digits do not have character options, then continue to use the digits themselves.
The operation of the program is as follows:
Implementation Details:
Grading: here is a quick breakdown of the functionality to motivate you to solve this problem incrementally!
Here are some examples of invalid phone numbers:
866-394=4930 443-4567-543 443-2a4-54i3 410-516-411723 (234) 432-2345
Here are two sample runs:
------------------------
enter 10-digit phone number xxx-xx-xxxx or (xxx)xxx-xxxx and name:
410-231-4059 Mr. & Mrs. Smith
Mr. & Mrs. Smith's number is probably a local land line
Associated characters:
2314059
ad g jw
be h kx
cf i ly
z
After eliminating non-related characters...
2314059
h
i
Possible pneumonics:
231h059
231i059
-------------------------
enter 10-digit phone number xxx-xx-xxxx or (xxx)xxx-xxxx and name:
(800)347-7866 Firestone
Firestone's number is a toll-free line
Associated characters:
3477866
dgpptmm
ehqqunn
firrvoo
ss
After eliminating non-related characters...
3477866
eirrtnn
f ss oo
Possible pneumonics:
eirrtnn
eirrtno
eirrton
eirrtoo
eirstnn
eirstno
eirston
eirstoo
eisrtnn
eisrtno
eisrton
eisrtoo
eisstnn
eisstno
eisston
eisstoo
firrtnn
firrtno
firrton
firrtoo
firstnn
firstno
firston
firstoo
fisrtnn
fisrtno
fisrton
fisrtoo
fisstnn
fisstno
fisston
fisstoo