Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class VowelsCount
- {
- public static void main(String[] args)
- {
- Scanner in = new Scanner(System.in);
- System.out.println("Please enter a word or a sentence:");
- String line = in.nextLine();
- char letter ;
- int countOfVowels=0;
- for (int i = 0; i <line.length() ; i++) {
- letter = line.toLowerCase().charAt(i);
- switch (letter){
- case 'a':
- case 'e':
- case 'i':
- case 'o':
- case 'u':
- countOfVowels++;
- break;
- }
- }
- System.out.println("Count of vowels in this word/sentence is: " + countOfVowels);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement