2000字范文,分享全网优秀范文,学习好帮手!
2000字范文 > 电话键盘(提示用户输入一个小写或大写字母 然后显示对应数字)

电话键盘(提示用户输入一个小写或大写字母 然后显示对应数字)

时间:2023-08-11 10:04:17

相关推荐

电话键盘(提示用户输入一个小写或大写字母 然后显示对应数字)

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;}}}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。