Question

In: Computer Science

Write pseudocode for a function that translates a telephone number with letters in it (such as...

Write pseudocode for a function that translates a telephone number with letters in it (such as 1-800-FLOWERS) into the actual phone number. Use the standard letters on a phone pad

Solutions

Expert Solution

Take the first character.

Covert A, B, and C to 2,

D, E, and F to 3,

G, H, and I to 4,

J, K, and L to 5,

and M, N, and O to 6,

P, Q, R, and S to 7,

T, U, and V to 8,

and W, X, Y, and Z to 9 .

CODE:

Initialize actual phone number to the empty string

For each character in the phone number

If the character is A, B or C

     Append a 2 to the end of actual phone number

Else if the character is D, E or F

     Append a 3 to the end of actual phone number

Else if the character is G, H or I

    Append a 4 to the end of actual phone number

Else if the character is J, K or L

    Append a 5 to the end of actual phone number

If the character is M, N, O

     Append a 6 to the end of actual phone number

Else if the character is P,Q,R,S

    Append a 7 to the end of actual phone number

Else if the character is T,U,V

    Append a 8 to the end of actual phone number

Else if the character is W,X,Y,Z

    Append a 9 to the end of actual phone number

---------------------------------------------------Please Upvote-----------------------------------------------------------------------


Related Solutions

Give pseudocode for a recursive function that sorts all letters in a string. For example, the...
Give pseudocode for a recursive function that sorts all letters in a string. For example, the string "goodbye" would be sorted into "bdegooy". Java
Give pseudocode for a recursive function that sorts all letters in a string. For example, the...
Give pseudocode for a recursive function that sorts all letters in a string. For example, the string "goodbye" would be sorted into "bdegooy". Python
Write a function called tokenizeTelNum that inputs a telephone number as a string in the form...
Write a function called tokenizeTelNum that inputs a telephone number as a string in the form (555) 555-5555. The function should use the function strok to extract the area code as a token, the first three digits of the phone number as a token and the last four digits of the phone number as a token. The seven digits of the phone number should be concatenated into one string. The function should convert the area code string to int and...
To make telephone numbers easier to remember, some companies use letters to show their telephone number....
To make telephone numbers easier to remember, some companies use letters to show their telephone number. For example, using letters, the telephone number 438-5626 can be shown as GET LOAN. In some cases, to make a telephone number meaningful, companies might use more than seven letters. For example, 225-5466 can be displayed as CALL HOME, which uses eight letters. Instructions Write a program that prompts the user to enter a telephone number expressed in letters and outputs the corresponding telephone...
Write a PYTHON function CommonLetters(mystring) that takes mystring as input and returns the number of letters...
Write a PYTHON function CommonLetters(mystring) that takes mystring as input and returns the number of letters in mystring that also occur in the string ‘Python’. Using above function, write a program that repeatedly prompts the user for a string and then prints the number of letters in the string that are also in string ‘Python’. The program terminates when the user types an empty string.
Modify Java program to accept a telephone number with any numberof the letters, using the...
Modify Java program to accept a telephone number with any number of the letters, using the if else loop. The output should display a hyphen after the first 3 digits and subsequently a hyphen (-) after every four digits. Also, modify the program to process as many telephone numbers as the user wants.
Write a program that translates a letter grade into a number grade. Letter grades are A,...
Write a program that translates a letter grade into a number grade. Letter grades are A, B, C, D, and F, possibly followed by + or -. Their numeric values are 4, 3, 2, 1 and 0. There is no F+ or F-. A “+” increases the numeric value by 0.3, a “–“ decreases it by 0.3. However, an A+ has value 4.0.4 pts Enter a Letter grade: B- The numeric value is 2.7 Your code with comments A screenshot...
(Tokenizing Telephone Numbers) Write a program that inputs a telephone number as a string in the...
(Tokenizing Telephone Numbers) Write a program that inputs a telephone number as a string in the form (555) 555-5555. The program should use function strtok to extract the area code as a token, the first three digits of the telephone number as a token and the last four digits of the phone number as a token. The seven digits of the phone number should be concatenated into one string. The program should convert the area-code string to int and convert...
Tokenizing Telephone Numbers Write java application that inputs a telephone number as a string in the...
Tokenizing Telephone Numbers Write java application that inputs a telephone number as a string in the form (555) 555-5555. The application should use String method split to extract the area code as a token, the first three digits of the phone number as a token and the last four digits of the phone number as a token. The seven digits of the phone number should be concatenated into one string. Both the area code and the phone number should be...
Use python write a function that translates the input string into Pig Latin. The translation should...
Use python write a function that translates the input string into Pig Latin. The translation should be done word by word, where all words will be separated by only one space. You may assume that each word must have at least one vowel (a,e,i,o,u and uppercased counterparts), and there will be no punctuation or other special characters in the input string. The Pig Latin rules are as follows: For words that begin with consonants, all letters before the initial vowel...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT