-
Notifications
You must be signed in to change notification settings - Fork 132
Expand file tree
/
Copy pathCount_Word_Vowel.java
More file actions
34 lines (33 loc) · 809 Bytes
/
Count_Word_Vowel.java
File metadata and controls
34 lines (33 loc) · 809 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
34
/* Count the words in a sentence which are start with vowel.
*
* Input: Arijit is student of MCA
* Output: 3
*
* Input: Sara plays tennis
* Output: No such words
*/
import java.util.*;
public class Count_Word_Vowel {
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
String s = sc.nextLine().toLowerCase();
String[] arr = s.split(" ");
int count=0;
for (int i = 0; i < arr.length; i++) {
char d = arr[i].charAt(0);
if(d=='a' || d=='e' || d=='i' || d=='o' || d=='u')
{
count++;
}
}
if(count>0)
{
System.out.println(count);
}
else
{
System.out.println("No such words");
}
}
}