Question: IN C++ PLEASE Topics Branching switch statement Description Write a program that translates a letter used in a telephone number into an equivalent numeric digit.

IN C++ PLEASE

Topics

Branching

switch statement

Description

Write a program that translates a letter used in a telephone number into an equivalent numeric digit. The program asks the user to enter a letter, translates the letter into the corresponding digit and displays it. The user may enter its selection either as an upper or lower case letter.

The program translates the letter into a digit according to the table below:

Letters Digit

a b c 2

d e f 3

g h i 4

j k l 5

m n o 6

p q r s 7

t u v 8

w x y z 9

Testing

Input Test 1

Enter a letter: p

Output Test 1

Letter: p

Digit: 7

Input Test 2

Enter a letter: P

Output Test 1

Letter: P

Digit: 7

Sample Code 1

char letter;

int digit;

cout << Enter a single alphabet character << endl;

cin >> letter;

switch (letter)

{

case 'a':

case 'b':

case 'c':

case 'A':

case 'B':

case 'C':

digit = 2;

break;

case 'd':

case 'e':

case 'f':

case 'D':

case 'E':

case 'F':

digit = 3;

break;

//add more cases below

}

cout << "Letter: " << letter << endl;

cout << "Digit: " << digit << endl;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!