Title Description
Enter a line of characters to count the number of letters, spaces, numbers, and other characters that contain English.
Input Description:
Enter a line of string, you can have spaces
Output Description:
Statistics of English characters, space characters, numeric characters, number of other characters
Input Example:
1qazxsw23 edcvfr45tgbn Hy67uj m,ki89ol.\\/;p 0-=\\][
Output Example:
2631012
<span style= "FONT-SIZE:18PX;" >import java.util.*;p ublic class Main {public static void main (string[] args) {Scanner scan=new Scanner (system.in); int Eng=0,space=0,num=0,other=0;while (Scan.hasnext ()) {char[] Chars=scan.nextline (). ToCharArray (); for (char Ch:chars) { if ((ch>= ' a ' &&ch<= ' z ') | | (ch>= ' A ' &&ch<= ' Z ')) {eng++;} else if (ch== ') {space++;} else if (ch>= ' 0 ' &&ch<= ' 9 ') {num++;} else{other++;}} System.out.println (eng+ "\ n" +space+ "\ n" +num+ "\ n" +other);}}} </span>
Huawei oj--Enter a line of characters to count the number of letters, spaces, numbers, and other characters