I am currently in doing a program which is given by my tutor:
Contemplate that you are working for the phone company and want to sell "special" phone numbers to companies. These phone numbers are "special" because they are easily translated into words. You've been asked to create a list of phone numbers that are directly mappable to words by searching a dictionary for every 7 or 10 letter word that maps on to the phone lettering scheme:
ABC - "2" DEF - "3"
GHI - "4" JKL - "5" MNO - "6"
PRS - "7" TUV - "8" WXY - "9"
Given these letters, the word xylophones is really the phone number 995-674-6637
The word, yipping is the phone number 947-7464
Specifics:
1. You will write three functions, detailed below.
2. You must search through all the words in the stored in a file, checking to see which ones are valid phone numbers.
3. You should use the strlen function to determine the length of each word.
4. Each word is on a separate line of the file. You are required to use the fgets function to read each word (line).
5. Your program should write (save) each word that corresponds to a number (followed by its number) into a file.
6. You must count how many 7 or 10 letter words are in the file and how many of these words translate into phone numbers. You should print the percentage (to 1 decimal place) at the end of your program, either into a file or to the screen.
An example of the last couple of lines of you’re the output would be:
...
word yesteryear is the phone number 937-837-9327
word yipping is the phone number 947-7464
word yttrium is the phone number 988-7486
96.8 percent of the 7/10 letter words that were translatable into phone numbers
7. You will be using a string parameter for one of your functions. A string is just an array of characters. When you don't know how long an array parameter will be (how many values it will contain), you can use empty [] to represent the fact that it is an array of unknown length. Thus function(char my_string[]) would be a function that takes a string of indeterminate length.
8. Your main function should return 0 upon completion.
Required functions:
1. Write a function to check phone numbers where this function takes in a string representing the dictionary word and returns a string representing the appropriate phone number. The phone number should be set to the "empty" string if the word does not form a phone number.
2. Write another function that takes in a single character and returns the associated phone digit (as a character). For example, the character 'A' would return '2'. For this program, you are to ignore the case of the character (thus 'g' and 'G' would return 4. If the character does not appear as a number on the phone, your function is to return '0' to signal this fact.
3. Write the main function that should open the input file containing the words and the output file to store the output. It should then read every word from the input file (one at a time) and as it reads each word, call the function to check the phone number to see if it is convertible. If the word forms a valid phone number of 7 or 10 letters, print this information into the output file. Finally, print the percentage of valid phone numbers that can be derived (either to the output file or to the screen) and then close the output and input files.
Can anyone help me?