描述
请从标准输入流(控制台)中获取一个由大写字母和小写字母组成的字符串 s,并通过 System.out.println 语句输出 s 中小写字母的个数。
1 ≤ s 的 长 度 ≤ 40 1 \leq s的长度 \leq 40 1≤s的长度≤40
样例
评测机会将整个项目的代码编译为一个可执行的 Main 程序,并按照这样的方式执行你的代码 Main。你的代码需要从标准输入流(控制台)中读入数据 s,计算出结果并打印到标准输出流(控制台)中。
样例一
当 s = ‘Apple’ 时,程序执行打印出的结果为:
4
样例二
当 s = ‘AAA’ 时,程序执行打印出的结果为:
0
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// write your code here
// read data from console
// output the answer to the console according to the
// requirements of the question
Scanner sc = new Scanner(System.in);
String s = sc.nextLine();
int count = 0;
for(int i=0;i<s.length();i++){
if((int)s.charAt(i)>=97 && (int)s.charAt(i)<=122){
count++;
}
}
System.out.println(count);
}
}