Question

Write a C++ program that inputs a single letter and prints out the corresponding digit on the...

Write a C++ program that inputs a single letter and prints out the corresponding digit on the telephone.
The letters and digits on a telephone are grouped this way:
2 = ABC 4 = GHI 6 = MNO 8 = TUV
3 = DEF 5 = JKL 7 = PRS 9 = WXY
No digits correspond to either Q or Z. For these two letters, your program should print a message
indicating that they are not used on a telephone. If a letter in lower case or a non-alphabetic character is
entered, your program should indicate that there is no matching digit for such character
0 0
Add a comment Improve this question Transcribed image text
Answer #1

prompt Enter a character:

read char

if entered character isAlpha and isUpper

then if(char==A or char==B or char==C)

        then print(2)

        else if(char==D or char==E or char==F)
        then print(3)

        else if(char==G or char==H or char==I)
        then print(4)

        else if(char==J or char==K or char==L)
        then print(5)

        else if(char==M or char==N or char==O)
        then print(6)

        else if(char==P or char==Q or char==R or char==S)
        then print(7)

        else if(char==T or char==U or char==V)
        then print(8)

        else if(char==W or char==X or char==Y OR char==Z)
        then print(9)

else

then...


answered by: Manuel
Add a comment
Know the answer?
Add Answer to:
Write a C++ program that inputs a single letter and prints out the corresponding digit on the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • hello. i need help with number 2 ONLY 1. Use if statements to write a Java...

    hello. i need help with number 2 ONLY 1. Use if statements to write a Java program that inputs a single letter and prints out the corresponding digit on the telephone. The letters and digits on a telephone are grouped this way 2=ABC 3 = DEF 4 GHI 5 JKL 6 - MNO 7 - PRS 8 - TUV 9-WXY No digit corresponds to either Qor Z. For these 2 letters your program should print a message indicating that they...

  • Phone Number Problem (Use Object-Oriented Programming Style. Otherwise there will be no credit) Write a C++ program tha...

    Phone Number Problem (Use Object-Oriented Programming Style. Otherwise there will be no credit) Write a C++ program that can convert any 7-digit telephone number into corresponding words where the equivalence of each digit and its corresponding characters is defined in the telephone keypad, which is shown in the following table: ABC 4 1 JKL MNO 8 TUV WXYZ In the keypad, there is no equivalence for digit 1 and 0, but in reality, the phone number might contain those two...

  • in C++ Description The purpose of this challenge is to manually manipulate character arrays. This challenge...

    in C++ Description The purpose of this challenge is to manually manipulate character arrays. This challenge converts text in phone numbers to their equivalent values on a phone keypad. Requirements Write a program to decode phone numbers with letters in them. Create a void function decodetext(char after[], char before[]). This function should be case-insensitive. Do NOT cout in this function. Declare a char array to hold a maximum of 50 characters. Ask the user to enter a string. Use cin.getline(char_variable,...

  • This is Python The program should accept input from the user as either 7-digit phone number...

    This is Python The program should accept input from the user as either 7-digit phone number or 10-digit. If the user enters 7 characters, the program should automatically add "512" to the beginning of the phone number as the default area code. Dash (hyphen) characters do not count in input character count, but must not be random. If the user enters dashes the total character count must not exceed 12. The program should not crash if the user enters invalid...

  • Write a program that inputs a string from the user representing a password, and checks its...

    Write a program that inputs a string from the user representing a password, and checks its validity. A valid password must contain: -At least 1 lowercase letter (between 'a' and 'z') and 1 uppercase letter (between 'A' and 'Z'). -At least 1 digit (between '0' and '9' and not between 0 and 9). At least 1 special character (hint: use an else to count all the characters that are not letters or digits). -A minimum length 6 characters. -No spaces...

  • This C# program prints out a corresponding letter grade for a given mark. It uses a...

    This C# program prints out a corresponding letter grade for a given mark. It uses a method (called MarktoGrade) to determine the letter grade. MarktoGrade takes one integer call by value formal parameter (called mark) and returns a char value that is the letter grade. All of the input and output (except an error message) is done in Main. There is one syntax error in this program that you will need to fix before it will compile (the error is...

  • in C++, Design a program that asks the user to enter a password, and then analyze...

    in C++, Design a program that asks the user to enter a password, and then analyze the password, and then analyze the password for the following weaknesses: 1. Fewer than 8 characters 2. Does not contain at least one uppercase letter and one lowercase latter 3. Does not contain at least one numeric digit 4. Does not contain at least one special character( a character that is not a letter or numeric digit) 5. Is a sequence of consecutive uppercase...

  • Write a complete C program that inputs a paragraph of text and prints out each unique...

    Write a complete C program that inputs a paragraph of text and prints out each unique letter found in the text along with the number of times it occurred. A sample run of the program is given below. You should input your text from a data file specified on the command line. Your output should be formatted and presented exactly like the sample run (i.e. alphabetized with the exact spacings and output labels). The name of your data file along...

  • Question 1: Consider the following specification for a program. The program reads two inputs from the...

    Question 1: Consider the following specification for a program. The program reads two inputs from the user: a string s and an integer number n. The program concatenates s with itself n-1 times, if the following conditions are satisfied: 1- s consists of 3 characters. 2- The first character in s is a letter. 3- s consists of letters (A-Z a-z) and digits only (0-9) 4-0< n<5 If any of these conditions is not satisfied, the program terminates and prints...

  • Regular C Programming It is just a random generator of telephone numbers DESCRIPTION To make telephone...

    Regular C Programming It is just a random generator of telephone numbers DESCRIPTION To make telephone numbers easier to remember, some companies use letters to show their telephone number, but mapping the letters to the numbers on a standard telephone keypad: 1 2 ABC 3 DE 4G 5 11 6 MNO 7 PONS 8 Tu 9.xyz # For example, using letters & spaces, the telephone number 438-5626 can be shown as GET LOAN. In some cases, to make a telephone...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT