-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringCheckDemo.java
More file actions
32 lines (28 loc) · 878 Bytes
/
Copy pathStringCheckDemo.java
File metadata and controls
32 lines (28 loc) · 878 Bytes
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
import java.util.Scanner;
public class StringCheckDemo {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int v,c,spch,sp;
v = c = spch = sp = 0;
System.out.println("Enter The String : ");
String str = s.nextLine();
for(int i = 0; i<str.length(); i++) {
char ch = str.charAt(i);
if((ch >= 'A' && ch <='Z') || (ch >= 'a' && ch <= 'z')) {
if(ch == 'a'|| ch == 'A' || ch == 'E' || ch == 'e' || ch == 'i' || ch == 'I' || ch == 'o' || ch =='O' || ch =='U'|| ch =='u' )
v++;
else
c++;
}
else if(ch == ' ')
sp++;
else
spch++;
}
System.out.println(str);
System.out.println("Vowel Count : " + v);
System.out.println("Consonant Count : " + c);
System.out.println("Space Count : " + sp);
System.out.println("Special Character Count : " + spch);
}
}