Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

JAVA ASSIGNMENT3

1.WAP to take input for 1-d string array and calculate no of vowels present in every element and print
the same element wise.

public class vowel_search {


public static void main(String args[]) {

String str = new String("My Name is Sourav");


for(int 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') {
System.out.println("Given string contains "+str.charAt(i)+" at the
index "+i);
}
}
}
}

You might also like