Computer Science, asked by Raviraj95, 1 year ago

answer me fast plzzzzzzzz! in java pls

Attachments:

Answers

Answered by siddhartharao77
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 !!!!
siddhartharao77: thank you!
silu12: superb✌️
siddhartharao77: Thank you!
Similar questions