Java"编写一个程序,根据用户输入的一个字符,判断字符是不是字母,如果是字母,判断该字母是声母换 100
Java"编写一个程序,根据用户输入的一个字符,判断字符是不是字母,如果是字母,判断该字母是声母换是韵母,是大写是小写字母,如果不是不是字母,则输出你输入的字符不是字母"...
Java"编写一个程序,根据用户输入的一个字符,判断字符是不是字母,如果是字母,判断该字母是声母换是韵母,是大写是小写字母,如果不是不是字母,则输出你输入的字符不是字母"求程序代码,用if或switch做
展开
展开全部
public static void main(String[] args) {
//小写声母
String[] ch1={"b","p","m","f","d","t","n","l","g","k","h","j","q","x","zh","ch","sh","r","z","c","s","y","w"};
//大写声母
String[] ch11={"B","P","M","F","D","T","N","L","G","K","H","J","Q","X","ZH","CH","SH","R","Z","C","S","Y","W"};
//小写韵母
String[] ch2={"a"," o", "e"," i", "u","v"};
//大写韵母
String[] ch22={"A"," O", "E","I", "U","V"};
Scanner sn=new Scanner(System.in);
while(true){
System.out.println("请输入:");
String str=sn.next();
boolean isWord=false;
for(int i=0;i<ch1.length;i++){
if(str.equals(ch1[i])){
System.out.println("小写声母:"+str);
isWord=true;
break;
}
}
for(int i=0;i<ch11.length;i++){
if(str.equals(ch11[i])){
System.out.println("大写声母:"+str);
isWord=true;
break;
}
}
for(int i=0;i<ch2.length;i++){
if(str.equals(ch2[i])){
System.out.println("小写韵母:"+str);
isWord=true;
break;
}
}
for(int i=0;i<ch22.length;i++){
if(str.equals(ch22[i])){
System.out.println("大写韵母:"+str);
isWord=true;
break;
}
}
if(! isWord){
System.out.println("不是字母"+str);
}
}
}
//小写声母
String[] ch1={"b","p","m","f","d","t","n","l","g","k","h","j","q","x","zh","ch","sh","r","z","c","s","y","w"};
//大写声母
String[] ch11={"B","P","M","F","D","T","N","L","G","K","H","J","Q","X","ZH","CH","SH","R","Z","C","S","Y","W"};
//小写韵母
String[] ch2={"a"," o", "e"," i", "u","v"};
//大写韵母
String[] ch22={"A"," O", "E","I", "U","V"};
Scanner sn=new Scanner(System.in);
while(true){
System.out.println("请输入:");
String str=sn.next();
boolean isWord=false;
for(int i=0;i<ch1.length;i++){
if(str.equals(ch1[i])){
System.out.println("小写声母:"+str);
isWord=true;
break;
}
}
for(int i=0;i<ch11.length;i++){
if(str.equals(ch11[i])){
System.out.println("大写声母:"+str);
isWord=true;
break;
}
}
for(int i=0;i<ch2.length;i++){
if(str.equals(ch2[i])){
System.out.println("小写韵母:"+str);
isWord=true;
break;
}
}
for(int i=0;i<ch22.length;i++){
if(str.equals(ch22[i])){
System.out.println("大写韵母:"+str);
isWord=true;
break;
}
}
if(! isWord){
System.out.println("不是字母"+str);
}
}
}
展开全部
public class SwitchTest {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
while (true) {
System.out.println("请输入一个字符");
String line = input.next();
if (line.length() > 1){
continue;
}
char c = line.charAt(0);
if (Character.isDigit(c))
System.out.println(c + " 是数字");
else if (Character.isAlphabetic(c)) {
switch (c) {
case 'a':
case 'A':
case 'e':
case 'E':
case 'i':
case 'I':
case 'o':
case 'O':
case 'u':
case 'U':
System.out.print(c + " 是韵母");break;
default:
System.out.print(c+" 是声母");
}
if (Character.isUpperCase(c))
System.out.println(",也是大写字母");
else
System.out.println(",也是小写字母");
}else
System.out.println(c + " 是特殊字符");
}
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询