-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCount.java
More file actions
46 lines (41 loc) · 1.01 KB
/
Count.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
*/
public class Count {
public static void main(String args[]){
String s=new String("I Love Java Programming @version 1.8");
int i;
char ch;
int count=0;
int count1=0;
int count2=0;
int count3=0;
int length=s.length();
//System.out.println(length);
for(i=0;i<length;i++)
{
ch=s.charAt(i);
if(Character.isLetter(ch))
{
count++;
}
else if (Character.isDigit(ch))
{
count1++;
}
else if(Character.isWhitespace(ch))
{
count2++;
}
else if(!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);
}
}