-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathString_vowel_conso.java
More file actions
33 lines (24 loc) · 916 Bytes
/
Copy pathString_vowel_conso.java
File metadata and controls
33 lines (24 loc) · 916 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
33
import java.util.Scanner;
public class String_vowel_conso {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter a string to count Vowel Consonent in it :");
String new_string = sc.nextLine();
int Vcnt = 0;
int Ccnt = 0;
new_string = new_string.toLowerCase();
for(int i = 0; i<new_string.length();i++)
{
if(new_string.charAt(i)=='a' || new_string.charAt(i)=='e' || new_string.charAt(i)=='i'|| new_string.charAt(i)=='o' ||new_string.charAt(i)=='u'){
Vcnt++;
// System.out.println("Vowel count in the String is " + Vcnt);
}
else {
Ccnt++;
// System.out.println("Consonent count in the String is " + Ccnt);
}
}
System.out.println("Vowel count in the String is " + Vcnt);
System.out.println("Consonent count in the String is " + Ccnt);
}
}