Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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

ID: 3620077 • Letter: W

Question

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

Explanation / Answer

please rate - thanks #include<iostream>
using namespace std;
int main()
{
char c;
cout<<"enter a letter: ";
cin>>c;
cout<<"Telephone key: ";
switch(c)
{
case 'A': case 'B': case 'C':
      cout<<"2 ";   
      break;
case 'D': case 'E': case 'F':
      cout<<"3 ";
      break;
case 'G': case 'H': case 'I':
      cout<<"4 ";
      break;
case 'J': case 'K': case 'L':
      cout<<"5 ";
      break;
case 'M': case 'N': case 'O':
     cout<<"6 ";
     break;
case 'P': case 'R': case 'S':
      cout<<"7 ";
      break;
case 'T': case 'U': case 'V':
      cout<<"8 ";
      break;
case 'W': case 'X': case 'Y':
      cout<<"9 ";
      break;
case 'Q':case 'Z':
       cout<<"Not on a telephone ";
       break;
default:
      cout<<"No matching digit for this character ";
}
system("pause");
return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote