-
Notifications
You must be signed in to change notification settings - Fork 0
/
Expt_9.java
33 lines (31 loc) · 968 Bytes
/
Expt_9.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
public class Expt_9 {
public static void main(String[] args) {
String test="Aa kiu,I swdskieo 236587.GH kiu:sieo??25.33";
count(test);
}
public static void count(String x){
char[]ch=x.toCharArray();
int letter=0;
int space=0;
int num=0;
int other=0;
for(int i=0;i<x.length();i++){
if(Character.isLetter(ch[i])){
letter++;
}
else if(Character.isDigit(ch[i])){
}
else if (Character.isSpaceChar(ch[i])){
space++;
}
else{
other++;
}
}
System.out.println("The string is:Aa kiu,I swdskieo 236587.GH kiu:sieo??25.33");
System.out.println("letter:"+letter);
System.out.println("space:"+space);
System.out.println("number:"+num);
System.out.println("other:"+other);
}
}