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

Telephone keypads have an international standard for mapping the alphabet to the

ID: 3802552 • Letter: T

Question

Telephone keypads have an international standard for mapping the alphabet to the number keys. This can be seen in the image below: Write a program which can take a series of 10 letters and converts them to the corresponding phone number. Input Validation: bullet The input must be exactly 10 characters, no more, no less. Requirements: bullet The output must be formatted in the following format (###) ###-####. bullet You are NOT allowed to use loops or arrays. You may only use coding techniques found in chapters. bullet Your program must work for any input. Sample Output: Enter input: CODEISLIFE Phone Number: (263) 347-5433

Explanation / Answer


#include <cmath>
#include <iostream>
   using namespace std;
   int main()
  
   {
   // variable declaration.
   string letter;
   char wish_convert;
  
   cout<<"This Program will convert letters to thier corresponding telephone "
   "digit."<<endl;
   cout<<"Are you wish to convert letters into a telephone number."<<endl;
   cin>>wish_convert;
   cout<<endl;
   if(wish_convert == 'Y' || wish_convert == 'y'){
   cout<<"Please enter a letter: "<<endl;
   cin>>letter;
   cout<<endl;}
   else
   cout<<"Thank You."<<endl;   
   do {
   //Switch statement to determine number.
   switch (letter[0])
   {
   case 'A':
   case 'a':
   case 'B':
   case 'b':
   case 'C':
   case 'c':
   cout<<2<<endl;
   break;
   case 'D':
   case 'd':
   case 'E':
   case 'e':
   case 'F':
   case 'f':
   cout<<3<<endl;
   break;
   case 'G':
   case 'g':
   case 'H':
   case 'h':
   case 'I':
   case 'i':
   cout<<4<<endl;
   break;
   case 'J':
   case 'j':
   case 'K':
   case 'k':
   case 'L':
   case 'l':
   cout<<5<<endl;
   break;
   case 'M':
   case 'm':
   case 'N':
   case 'n':
   case 'O':
   case 'o':
   cout<<6<<endl;
   break;
   case 'P':
   case 'p':
   case 'Q':
   case 'q':
   case 'R':
   case 'r':
   case 'S':
   case 's':
   cout<<7<<endl;
   break;
   case 'T':
   case 't':
   case 'U':
   case 'u':
   case 'V':
   case 'v':
   cout<<8<<endl;
   break;
   case 'W':
   case 'w':
   case 'X':
   case 'x':
   case 'Y':
   case 'y':
   case 'Z':
   case 'z':
   cout<<9<<endl;
   break;
   }}
   while (letter[0,1,2,3,4,5,6,7,8,9] );
     
   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