The number of figures, letters, spaces, etc.

java.util.Scanner Import; 


public class the Text { 


public static void main (String [] args) { 
// the TODO Auto-Generated Method Stub 
 int Shuzi = 0; // Analyzing digital 
 int kongge = 0; // Analyzing spaces 
 int yingwen = 0; // Analyzing English 
 int qita = 0; // Analyzing other characters 
   Scanner Scanner new new INPUT = (the System.in); 
   String input.nextLine A = (); 
    char [] Ar = a.toCharArray (); 
  for ( 0 = I int; I <ar.length; I ++) { 
    iF (by Character.isDigit (Ar [I])) { 
      // isDigit determines whether digital array 
      Shuzi ++; 
      } the else iF (Character.isSpaceChar (Ar [I] )) { 
        // isSpaceChar determines whether a space 
        kongge ++; 
      } the else iF (Character.isLetter (Ar [I])) { 
        // determines whether or not the letter isLetter
        ++ yingwen;
      the else {} 
        qita ++; 
    } 
} 
      System.out.println ( "the number of letters:" + yingwen); 
      System.out.println ( "digits:" + Shuzi); 
      System.out.println ( "the number of spaces: "+ kongge); 
      System.out.println (" additional number of characters: "+ qita); 
    } 


}

  

Guess you like

Origin www.cnblogs.com/chenjiajiale/p/12583939.html