public class Test7 {
public static void main(String[] args){
Scanner in=new Scanner(System.in);
System.out.println("请输入字符串:");
String str=in.next();
char[] ch1=str.toCharArray();
char[] ch2=new char[ch1.length];
for(int i=0;i
ch2[i]=ch1[i];
if(ch2[i] >= 97 && ch2[i] <= 122)
{
ch2[i]=(char)((int)ch2[i]-32);
System.out.print(ch2[i]);
}
else if(ch2[i] >= 65 && ch2[i] <= 90){
ch2[i]=(char)((int)ch2[i]+32);
System.out.print(ch2[i]);
}
else{
System.out.print("输入不符合要求");
}
}
}
}
分享: |
|