4. WAP to accept a line of text and count the number of vowels present in each word and print in the following format
Answers
Answered by
0
Answer:
import java.util.*;
import java.io.*;
public class Main
{
static boolean isVowel(char y){
if(y=='a' || y=='e' || y=='i' || y=='o' || y=='u'){
return true;
}
return false;
}
public static void main(String[] args) throws IOException {
int vowel = 0;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter a string:");
String x = br.readLine();
for(int i = 0; i < x.length();i++){
if(isVowel(x.charAt(i))){
vowel++;
}
}
System.out.println("The number of vowels in " + x + " is " + vowel);
}
}
Explanation:
Similar questions
Math,
2 days ago
Chemistry,
2 days ago
Computer Science,
4 days ago
Math,
4 days ago
Physics,
8 months ago