answer me fast plzzzzzzzz! in java pls
Attachments:
Answers
Answered by
7
Here is a small program to count the number of vowels in 1 word.
import java.util.*;
class Brainly
{
public static void main(String args[])
{
int a = 0;
char b;
String str;
System.out.println("Enter a word: ");
Scanner demo = new Scanner(System.in);
str = demo.nextLine();
System.out.print("The vowels are: ");
for(int i = 0; i < str.length(); i++)
{
b = str.charAt(i);
if(b == 'a' || b == 'e' || b == 'i' || b == 'o' || b == 'u' || b == 'A' || b == 'E' || b == 'I' || b == 'O' || b == 'U')
{
System.out.print(b + " ");
a++;
}
}
System.out.println(" ");
System.out.println("The number of vowels in the word:" +a);
}
}
Output:
Enter a word : Siddhu
The vowels are: i u
The number of vowels in the word : 2.
Hope this helps!
FuturePoet:
Well done !!!!
Similar questions
Chemistry,
7 months ago
Social Sciences,
7 months ago
English,
1 year ago
Social Sciences,
1 year ago