Question
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
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 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
This is what i have: what do i need to do to make it display the whole number
#include "stdafx.h"
#include
using namespace std;
int main()
{
char letter;
cout << "Program to prompt the user to enter a telephone number expressed in letters"
<< endl;
cout << "To stop the program enter #."
<< endl;
cout << "Enter a telephone number expressed in Uppercase letters: ";
cin >> letter;
cout << endl;
while (letter != '#')
{
cout << "The telephone you entered is: "
<< letter << endl;
cout << "The corresponding telephone "
<< "digit is: ";
switch (letter)
{
case 'A':
case 'B':
case 'C':
cout << "2" << endl;
break;
case 'D':
case 'E':
case 'F':
cout << "3" << endl;
break;
case 'G':
case 'H':
case 'I':
cout << "4" << endl;
break;
case 'J':
case 'K':
case 'L':
cout << "5" << endl;
break;
case 'M':
case 'N':
case 'O':
cout << "6" << endl;
break;
case 'P':
case 'Q':
case 'R':
case 'S':
cout << "7" << endl;
break;
case 'T':
case 'U':
case 'V':
cout << "8" << endl;
break;
case 'W':
case 'X':
case 'Y':
case 'Z':
cout << "9" << endl;
default:
cout << "Invalid input." << endl;
}
return 0;
}
}
Step by Step Solution
3.45 Rating (148 Votes )
There are 3 Steps involved in it
Step: 1
Python program to convert telephone number letters to digits Dialpad mapping DIALPAD 1 1 2 ABC 3 DEF ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started