+ 1

Telephone Numbers

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 an 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. Write a program that prompts the user to enter a telephone number expressed in letters and outputs the corresponding telephone number in digits. If the user enters more than seven letters, then process only the first seven letters.. Also output the - (hyphen) after the third digit. Allow the user to use both uppercase and lowercase letters as well as spaces between words. Moreover, your program should process as many telephone numbers as the user wants. https://sololearn.com/compiler-playground/cEP3FXUuGA6V/?ref=app https://sololearn.com/compiler-playground/cEP3FXUuGA6V/?ref=app

11th Sep 2024, 8:34 AM
M.Shaarif
M.Shaarif - avatar
3 Antworten
+ 1
M.Shaarif I have an alternative approach to your program. I posted is a a comment in your code, but it seems you deleted your code, so I'm reposting it here for others to refer to and improve further... https://sololearn.com/compiler-playground/cc7n8Xhjsyeb/?ref=app
12th Sep 2024, 2:12 PM
Bob_Li
Bob_Li - avatar
+ 4
Some years ago, my home phone number was: HI-JERRY That was pretty cool. :) Your program works fine. Not sure if there was a question or if you were just showing us what you've done. A couple minor suggestions: 1. Allow NUMBERS as input and don't convert those. 2. Allow upper and lowercase letters. 3. Accept the entire input as a string instead of one letter at time - easier to use in Code Bits. 4. Display the entire translated phone number at the end. 5. Your program, as written, does not work well in Code Bits unless someone puts in the input correctly. If you want to share it to others, maybe add some comments suggesting how to use it. Something like: /***** This program converts letters into a phone number. It will translate phrases like 212-GET-HELP into the matching phone number. Key Letters 1 none 2 ABC 3 DEF 4 GHI 5 JKL 6 MNO 7 PQRS 8 TUV 9 WXYZ 0 none To use this, provide the letters to convert to numbers on the phone pad. Enter one letter per line. Add a # at the very end. Input something like this: Sample Input: 2 1 2 G E T H E L P # *****/ It's a nice little program. Great job. A lot of fun.
11th Sep 2024, 1:58 PM
Jerry Hobby
Jerry Hobby - avatar
+ 1
It's a cool task. Are you having trouble with it? We won't do the work for you, if you can share your code someone can look at it and give you advice. Read here for more and update your question: https://sololearn.com/compiler-playground/Wek0V1MyIR2r/?ref=app https://sololearn.com/compiler-playground/W0uW3Wks8UBk/?ref=app
11th Sep 2024, 11:39 AM
Ausgrindtube
Ausgrindtube - avatar