Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Letter-phonenumber conversion (http://www.go4expert.com/forums/letter-phonenumber-conversion-t6146/)

rachet 1Sep2007 14:50

Letter-phonenumber conversion
 
I recently joined the university and in one of the subjects ("computer and program design) an assignment due 5th Sept had already been given to the students 2 months ago. No matter how hard I work I won't be able 2 complete the assignment in time and I would then have to do foundations in programming for half a year in order to continue. I know its not right to be greatly aided in an assignment but this is a difference between me taking a whole year doing foundation and me continuing with the rest of the class. I will do private tutoring in c-programming this long holidays and definitely catch up.Please lend me a helping hand in the following program. Any help will be greatly apreciated.

We are to write a program in 'C' that would translate a string of 7 or 10 character words into its corresponding number according to the layout of a phone pad. We were to write 3 functions as follows;

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.


Specifics:
-You must search through all the words in the stored in a file, checking to see which ones are valid phone numbers.
-You should use the strlen function to determine the length of each word.
-Each word is on a separate line of the file. You are required to use the fgets function to read each word (line).
-Your program should write (save) each word that corresponds to a number (followed by its number) into a file.
-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

-Your main function should return 0 upon completion.
__________________
Edit/Delete Message

DaWei 1Sep2007 20:14

Re: Letter-phonenumber conversion
 
I'm quite certain that you could put together an algorithm for this (how you would go about it) and express it in your native language in the time required. That would be called pseudo-code.

If it is truly not your fault then surely that would suffice to gain you some extension of time.

Most people I know will not do you work for you. Why? Because then you will get a job on false credentials, then someone will have to do your actual work for you when you get into the workplace.

I would suggest you get cracking and do the best you can.


All times are GMT +5.5. The time now is 07:14.