Vowel Count
Vowel Count
Problem Description
Return the number (count) of vowels in the given string
Logic Test Case 1
Input (stdin)
hello
Expected Output
2
Logic Test Case 2
Input (stdin)
hello world
Expected Output
3
CODE AREA
import java.io.*;
import java.util.*;
public class TestClass {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
String str = s.nextLine();
int i,c=0;
for (i = 0; i < str.length(); i++)
{
if (str.charAt(i) == 'a' || str.charAt(i) == 'e' || str.charAt(i) == 'i'
|| str.charAt(i) == 'o' || str.charAt(i) == 'u')
{
c++;
}
}
System.out.println(" "+c);
}
}
0 Comments