fork(1) download
  1. import java.util.*;
  2.  
  3. class Main{
  4. public static void main(String args[]) {
  5. Scanner sc = new Scanner(System.in);
  6. while(sc.hasNextLine()) {
  7. String[] s=sc.nextLine().split(" ");
  8. int upper=0;
  9. int lower=0;
  10. int number=0;
  11. for(int i=0;i<s.length;i++) {
  12. for(int j=0;j<s[i].length();j++) {
  13. if(s[i].charAt(j)>='a'&&s[i].charAt(j)<='z') {
  14. lower++;
  15. }else if(s[i].charAt(j)>='A'&&s[i].charAt(j)<='Z') {
  16. upper++;
  17. }else if(s[i].charAt(j)>='0'&&s[i].charAt(j)<='9') {
  18. number++;
  19. }
  20. }
  21. }
  22. System.out.println(lower+" "+upper+" "+number+" "+(s.length-1));
  23. }
  24. sc.close();
  25. }
  26. }
  27.  
Success #stdin #stdout 0.06s 2184192KB
stdin
This is String
SPACE    1    SPACE
 S a M p L e I n P u T     
0L1A2S3T4L5I6N7E8
stdout
10 2 0 2
0 10 1 8
5 6 0 11
0 8 9 0