-->
当前位置:首页 > 题库

PROGRAMMING:Alphanumeric conversion of telephone keyboard

Luz5年前 (2021-05-10)题库397
The correspondence between letters and numbers on the telephone keyboard in the international standard is shown in the figure below.
![ Alphanumeric conversion of telephone keyboard. JPG] (~ / 63e1eeca-8387-420e-a8db-c0547df24709. JPG)
Write a program to read an input letter from the keyboard and convert it into the corresponding number.
###Input format:
Input a character from the keyboard, the value range is "a ~ Z" or "a ~ Z". When multiple continuous characters are input, the first character is selected.
###Output format:
(1) If the input data is legal, the corresponding number is output, ranging from 2 to 9;
(2) If the input data is illegal, output the input character + "is an invalid input"
###Input sample 1:
Here is a set of inputs. For example:
```in
M
```
###Output sample 1:
The corresponding output is given here. For example:
```out
six
```
###Input sample 2:
Here is a set of inputs. For example:
```in
t
```
###Output sample 2:
The corresponding output is given here. For example:
```out
eight
```
###Input sample 3:
Here is a set of inputs. For example:
```in
0
```
###Output sample 3:
The corresponding output is given here. For example:
```out
0 is an invalid input
```







answer:If there is no answer, please comment
Try switch and the character fetching method in the character class.