从键盘上输入一批字符串,如果是字符,是大写,转换成小写;如果是非字符,转换成ASCII表下一个字符,并统计字符和非字符的个数
import java.util.*;
public class Test{
public static void main(String[]args){
//从键盘上输入一批字符串,如果是字符,是大写,转换成小写;如果是非字符,转换成ASCII表下一个字符,并统计字符和非字符的个数
Scanner input=new Scanner(System.in);
System.out.println("请输入");
String s=input.next();
int count1=0;
int count2=0;
int count3=0;
for(int i=0;i<s.length();i++){
char c=s.charAt(i);
if(c>=65&&c<=90){
c+=32;
count1++;
}
else if(c>=97&&c<=122){
c=c;
count2++;
}
else{c++;
count3++;}
System.out.print(c);
}
System.out.println("字母有"+(count1+count2));
System.out.println("非字母有"+count3);
}
}