import java.util.Scanner;
public class Number {
public static void main(String[] args) {
//键盘录入
Scanner sc = new Scanner(System.in);
System.out.println("请输入:");
/**用户输入的字符串*/
String ch= sc.nextLine();
/**将字符串转为自付数组*/
char[] s = ch.toCharArray();
int small = 0;
int big = 0;
int num = 0;
/**遍历字符数组*/
for(int x = 0;x<ch.length();x++)
{
if (s[x]>='a'&&s[x]<='z') {
small++;
}
else if (s[x]>='A'&&s[x]<='Z') {
big++;
}
else if (s[x]>='0'&&s[x]<='9') {
num++;
}
}
System.out.println(small+"--"+big+"--"+num);
}
}
|
|