Answer:
<em>import java.util.Scanner;</em>
<em>public class CountVowelsModularized {</em>
<em> public static void main(String[] args) {</em>
<em> Scanner in = new Scanner (System.in);</em>
//Prompt user to enter a string, receive it and assign to a variable<em> </em>
<em>System.out.println("Enter a string Value");</em>
<em> String word =in.nextLine();</em>
//Calling the method numVowels and passing the string
<em> System.out.println("The Number of vowels are " +numVowels(word.toLowerCase()));</em>
<em> }</em>
<em>}</em>
The method definition and complete program is given in the explanation section<em> </em>
Explanation:
<em>import java.util.Scanner;</em>
<em>public class CountVowelsModularized {</em>
<em> public static void main(String[] args) {</em>
<em> Scanner in = new Scanner (System.in);</em>
<em> System.out.println("Enter a string Value");</em>
<em> String word =in.nextLine();</em>
<em />
<em> System.out.println("The Number of vowels are " +numVowels(word.toLowerCase()));</em>
<em> }</em>
<em> public static int numVowels(String string) {</em>
<em> int counter = 0;</em>
<em> for (int i = 0; i < string.length(); i++) {</em>
<em> if (string.charAt(i) == 'a' || string.charAt(i) == 'e' || string.charAt(i) == 'i'</em>
<em> || string.charAt(i) == 'o' || string.charAt(i) == 'u') {</em>
<em> counter++;</em>
<em> }</em>
<em> }</em>
<em> return counter;</em>
<em> }</em>
<em>}</em>