#include <iostream>
using namespace std;
int main()
{
char L;
cout << "Press # to stop the program from running" << endl;
cout << "Input a letter: " ;
cin >> L;
while (L != '#' && L >= 'A' && L <= 'Z') {
cout << "Letter entered is: " << L << endl;
cout << "The corresponding telephone digit is: ";
switch (L) {
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;
break;
default:
break;
}
cout << "Input another letter to find out the number: ";
cin >> L;
}
return 0;
}
Comments
Leave a comment