-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprog1.java
More file actions
60 lines (45 loc) · 1.16 KB
/
Copy pathprog1.java
File metadata and controls
60 lines (45 loc) · 1.16 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package StringPrograms;
public class prog1 {
public static void main(String[] args) {
String a="Let me staRt 21134 @@#$";
m1(a);
}
public static void m1(String a) {
int capitalLetter=0;
int smallLetters=0;
int vowels=0;
int consonents=0;
int specialChar=0;
int numbers=0;
for(int i=0; i<a.length(); i++) {
char ch=a.charAt(i);
if((ch>='a' && ch<='z') || (ch>='A' && ch<='Z')) {
if(ch>='a' && ch<='z') {
smallLetters++;
}
else if(ch>='A' && ch<='Z') {
capitalLetter++;
}
if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u') {
vowels++;
}
else {
consonents++;
}
}
else if(ch>='0' && ch<='9') {
numbers++;
}
else if(ch!=' '){
specialChar++;
}
}
System.out.println("Number of Vowels: "+vowels);
System.out.println("Number of consonents: "+consonents);
System.out.println("Number of Special Char: "+specialChar);
System.out.println("Number of numbers: "+ numbers);
System.out.println("Number of Small Letters: "+smallLetters);
System.out.println("Number of Capital Letters: "+ capitalLetter);
System.out.println();
}
}