The operator < is undefined for the argument type(s) char, String 5
packagecom.csljc.test001;importjava.util.*;publicclasslianxi010{publicstaticvoidmain(...
package com.csljc.test001;
import java.util.*;
public class lianxi010 {
public static void main(String[] args) {
getChar gw=new getChar();
System.out.println("请输入星期几的大写首字母:");
char ch=gw.getChar();
switch(ch){
ch"M":
System.out.println("Monday");break;
ch"W":
System.out.println("wednsday");break;
case"F":
System.out.println("Friday");
break;
case"T":{
System.out.println("请输入第二个字母:");
char ch2=gw.getChar();
if(ch2=="U"){System.out.println("Tuesday");}
else if(ch2=="H"){System.out.println("Thursday");}
else{System.out.println("无此写法!");}
}break;
case"S":{System.out.println("请输入第二个字母:");}
char ch3=gw.getChar();
if(ch3=="U"){System.out.println("Sunday");}
else if(ch3=="A"){System.out.println("Saturday");}
else{System.out.println("无此写法!");}break;
default:System.out.println("无此写法!");
}
}
}
class getChar{
public char getChar(){
Scanner s=new Scanner(System.in);
String str =s.nextLine();
char ch=str.charAt(0);
if(ch<"A"||ch>"Z"){
System.out.println("输入错误,请重新输入!");
ch=getChar();
}
return ch;
}
} 展开
import java.util.*;
public class lianxi010 {
public static void main(String[] args) {
getChar gw=new getChar();
System.out.println("请输入星期几的大写首字母:");
char ch=gw.getChar();
switch(ch){
ch"M":
System.out.println("Monday");break;
ch"W":
System.out.println("wednsday");break;
case"F":
System.out.println("Friday");
break;
case"T":{
System.out.println("请输入第二个字母:");
char ch2=gw.getChar();
if(ch2=="U"){System.out.println("Tuesday");}
else if(ch2=="H"){System.out.println("Thursday");}
else{System.out.println("无此写法!");}
}break;
case"S":{System.out.println("请输入第二个字母:");}
char ch3=gw.getChar();
if(ch3=="U"){System.out.println("Sunday");}
else if(ch3=="A"){System.out.println("Saturday");}
else{System.out.println("无此写法!");}break;
default:System.out.println("无此写法!");
}
}
}
class getChar{
public char getChar(){
Scanner s=new Scanner(System.in);
String str =s.nextLine();
char ch=str.charAt(0);
if(ch<"A"||ch>"Z"){
System.out.println("输入错误,请重新输入!");
ch=getChar();
}
return ch;
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询