- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCount.java
More file actions
Latest commit
46 lines (41 loc) · 1.01 KB
/
Copy pathCount.java
File metadata and controls
46 lines (41 loc) · 1.01 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
/**
*
* @author Mudassar
*/
publicclassCount {
publicstaticvoidmain(Stringargs[]){
Strings=newString("I Love Java Programming @version 1.8");
inti;
charch;
intcount=0;
intcount1=0;
intcount2=0;
intcount3=0;
intlength=s.length();
//System.out.println(length);
for(i=0;i<length;i++)
{
ch=s.charAt(i);
if(Character.isLetter(ch))
{
count++;
}
elseif (Character.isDigit(ch))
{
count1++;
}
elseif(Character.isWhitespace(ch))
{
count2++;
}
elseif(!Character.isLetterOrDigit(ch))
{
count3++;
}
}
System.out.println("Letters:"+count);
System.out.println("Digits:"+count1);
System.out.println("Words:"+count2);
System.out.println("Special Symbols:"+count3+1);
}
}