IUP Computer Science
CO 110 Fall '99

Project #3
(Due 15 Oct 99)

Today many organizations that do business over the telephone use telephone numbers that have been made into words by replacing some or all of the digits with letters from the corresponding buttons on the telephone. Thus, instead of saying that its number is 743-7233, an organization may advertise its telephone number as RIFRAFF. For a local example, consider that Edgar Snyder & Assoc., which advertises on TV all the time, says its telephone number is 94EDGAR, instead of 943-3427.

Your program for project #3 is to read in one of the these word-like telephone numbers, to determine what the real telephone number is, and to display the result looking like a regular telephone number (with hyphen). You may assume that all word-like telephone numbers contain only uppercase letters or digits and are 7 characters long. There will be no Q and no Z in the word-like numbers, because standard telephones did not use those letters on any of the buttons.

The digit-letter correspondence is as follows:

2 ABC 3 DEF 4 GHI 5 JKL

6 MNO 7 PRS 8 TUV 9 WXY

There are no letters on the 0 and 1 buttons. If either of these is part of a word-like number, they must appear as themselves. For example, BIGRED1 (which corresponds to 244-7331).

Your program must prompt for and read in a word-like number, convert each letter to a digit, leave digits as is, check to be sure there is no Q or Z or other invalid character, and display the resulting all-number value with a hyphen between the third and fourth digit (or display an error message, if there is an invalid character).

You should use a functional decomposition approach for solving this problem, as illustrated in some of the examples in chapters 5 and 6 of the text. You MUST use a group of if statements to determine which digit corresponds to a letter; do NOT try to use some more powerful construct to replace the if statements.

Hand in a printout of your well-commented, program that uses the approved style for indenting, identifier naming, and layout. Also, hand in an image of the result window in which the program translates the number NYCPSU3 Make the image of the result window as you did for project #2.