import java.util.Scanner;
/**
* 編寫一個程序,判斷輸出一個字符串中大寫英文字母數,和小寫英文字母數,和其他非英文字母數
*
* @author arvin
*
*/
public class IfString {
public static void main(String[] args) {
int numUppercase = 0;// 大寫英文字母數
int numlowercase = 0;// 小寫英文字母數
int numOther = 0;// 其他非英文字母數
Scanner sc = new Scanner(System.in);
System.out.println("請輸入一個字符串:");
String getString = sc.next();
for (int i = 0; i < getString.length(); i++) {
char c = getString.charAt(i);//把每個元素摘出來
if (c >= 'a' && c <= 'z') {
numlowercase++;
} else if (c >= 'A' && c <= 'Z') {
numUppercase++;
} else {
numOther++;
}
}
System.out.println("大寫英文字母數:" + numUppercase + "小寫英文字母數:" + numlowercase + "非英文字母數:" + numOther);
sc.close();
}
}