-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCountvowel.java
More file actions
33 lines (28 loc) · 881 Bytes
/
Countvowel.java
File metadata and controls
33 lines (28 loc) · 881 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 Countvowel {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String s =sc.nextLine();
int count=0;
for (int i = 0; i < s.length(); i++) {
char c=s.charAt(i);
if(c=='a'||c=='A'||c=='e'||c=='E'||c=='i'||c=='I'||c=='o'||c=='O'||c=='u'||c=='U'){
count++;
}
}
System.out.println(count);
System.out.println("using TocharArray");
char[] ch=s.toCharArray();
int c1=0;
String s1="AaEeIiOoUu";
for (int i = 0; i < ch.length; i++) {
for (int j = 0; j <s1.length(); j++) {
if(ch[i]==s1.charAt(j)){
c1++;
}
}
}
System.out.println(c1);
sc.close();
}
}