Keyboard input string of characters and sequences of characters do removed, each of the number of characters calculated

public class test{

  static void main public (String [] args) {
      // keyboard input objects
      Scanner sc = new Scanner (System.in) ;

    // remove the keyboard input string of characters and character sequences do
      System.out.println ( "Please enter a string of characters:");
      String str = sc.next ();
      int numCount = 0, aCount = 0, ACount = 0, otherCount = 0;
      // for循环字符
      for (int i = 0; i < str.length(); i++) {
        char ch = str.charAt(i);

         // resolving string in lowercase letters and numbers and symbols 
         IF (CH> = '0' && CH <= '. 9') {// '0' - '. 9'
            numCount ++; // number of digits
         } else IF (CH> = 'A' && CH <= 'Z') {// 'A' - 'Z'
            Acount ++; // number lowercase
         } else if (ch> = ' A' && ch <= ' the Z ') {//' A '-' the Z '
            Acount ++; // number of uppercase letters
         } else {// the other symbols
            otherCount ++; // number of other characters
         }
      }
     System.out.println ( "string:" + str + "\ n digital:" + numCount + "\ n lowercase letters:" + aCount + "\ n capital letters:" + ACount + "\ n other characters:" + otherCount);

  }

}

Guess you like

Origin www.cnblogs.com/autumn-rains/p/11069154.html