JAVA分别统计输入字符串中大写字母和小写字母的个数

	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		System.out.print("请输入字母:");
		String str = sc.nextLine();
		int upper = fun1(str);
	    int lower = fun2(str);
	    System.out.println("大写字母数量=" + upper);
	    System.out.println("小写字母数量=" + lower);
	    sc.close();
	}
	public static int fun1(String str) {
		int count = 0;
		for (int i = 0; i < str.length(); i++) {
			char ch = str.charAt(i);
			if (ch >= 'A' && ch<='Z') 
				count++;
				}
		return count;
		}
			
	public static int fun2(String str) {
		int count = 0;
		for (int i = 0; i < str.length(); i++) {
			char ch = str.charAt(i);
			if (ch >= 'a' && ch<='z') 
				count++;
				}
		return count;
		}
}