Didart

Vowels Count

Oct 8th, 2021
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1. import java.util.Locale;
  2. import java.util.Scanner;
  3.  
  4. public class VowelsCount {
  5.     public static void main(String[] args) {
  6.         Scanner scanner = new Scanner(System.in);
  7.  
  8.         String text = scanner.nextLine().toLowerCase();
  9.  
  10.         printVowelsCount(text);
  11.     }
  12.  
  13.     private static void printVowelsCount(String text) {
  14.  
  15.         int count = 0;
  16.  
  17.         for (int index = 0; index <= text.length() - 1; index++) {
  18.             char currentSymbol = text.charAt(index);
  19.             if (currentSymbol == 'a' || currentSymbol == 'e'
  20.                     || currentSymbol == 'i' || currentSymbol == 'o'
  21.                     || currentSymbol == 'u') {
  22.                 count++;
  23.             }
  24.         }
  25.         System.out.println(count);
  26.     }
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment