package 学习;
import java.util.*;
public class study {
public static void main(String[] args) {
System.out.println("请输入字母");
Scanner input=new Scanner(System.in);
String string=input.nextLine();
char letter=string.charAt(0);//取输入的第一个字节
letter=Character.toLowerCase(letter);
switch(letter)
{
case 'a':
case 'b':
case 'c':
System.out.println("the number is 2");
break;
case 'd':
case 'e':
case 'f':
System.out.println("the number is 3");
break;
case 'g':
case 'h':
case 'i':
System.out.println("the number is 4");
break;
case 'j':
case 'k':
case 'l':
System.out.println("the number is 5");
break;
case 'm':
case 'n':
case 'o':
System.out.println("the number is 6");
break;
case 'p':
case 'q':
case 'r':
case 's':
System.out.println("the number is 7");
break;
case 't':
case 'u':
case 'v':
System.out.println("the number is 8");
break;
case 'w':
case 'x':
case 'y':
case 'z':
System.out.println("the number is 9");
break;
case ' ':
System.out.println("the number is 0");
break;
default:
System.out.println("非法输入");
break;
}
}
}
电话键盘(提示用户输入一个小写或大写字母,然后显示对应数字)
最新推荐文章于 2023-02-03 19:32:27 发布