1. Write a C++ program that converts uppercase letters to their corresponding telephone digits . The program should reads the letter 'A' through 'Z' and print the corresponding telephone digit. To stop the program, the user is prompted for the sentinel. which is '#'.
Sample Run:
*****************
Telephone Digits
*****************
Program to convert uppercase letters to their corresponding telephone digits.
To stop the program enter #.
Enter a letter: S
The letter you entered is S
The corresponding telephone digit is :7
Enter another uppercase letter to find its corresponding telephone digit. To stop the program enter #.
Enter a letter: @
Invalid input
Enter another uppercase letter to find its corresponding telephone digit. To stop the program enter #.
Enter a letter: A
The letter you entered is A
The corresponding telephone digit is :2
Enter another uppercase letter to find its corresponding telephone digit. To stop the program enter #.
Enter a letter: #
I would prefer a switch - more elegant IMO, can cope with upper & lower case, or make use of std::toupper (need to #include <locale> ) before the switch.
Really, i thought or was just one |. At least that works for me? Also he doesn't need uppercase or lowercase conversion because his letters are not referring to ASCII
The bit-wise or operator is |. The logical or operator is ||. As it happens, they will evaluate to the same true or false value for this particular example, nevertheless the logical or operator (||) is what is called for here - we don't care about the bit patterns of boolean values.