In this program you will learn how to count vowels in a String. Here you will be asked to enter a String of your own choice and then you will get the number of vowels from that String.
Description of the code:
In the program code given below, you will be asked to enter the String first as can be observed from the method of java.io.*; package which is BufferedReader();. The compiler will read the String once you enter it through readLine(); method. Then we have taken a variable- count = 0. Now, we have applied a loop here which will go up to the String's length and will find the number of vowels one by one as shown in the output.
The code of the program is given below:
Output of the program:
Enter the String:
This is a new world
There are 5 vowels
If you enjoyed this post then why not add us on Google+? Add us to your Circles
Liked it! Share this Tutorial