desislava_topuzakova

02. Vowels Count

Feb 7th, 2021
631
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.93 KB | None | 0 0
  1. import java.util.Locale;
  2. import java.util.Scanner;
  3.  
  4. public class ProjectsCreation {
  5.     public static void main(String[] args) {
  6.         Scanner scanner = new Scanner(System.in);
  7.         String text = scanner.nextLine().toLowerCase();
  8.         printVowelsCount(text);
  9.  
  10.     }
  11.  
  12.     static void printVowelsCount (String text) {
  13.         //a, e, i , o, u
  14.         int count = 0; //броим гласните букви
  15.         for (int index = 0; index <= text.length() - 1; index++) {
  16.             //взимаме символа -> проверка дали е гласна буква
  17.             char currentSymbol = text.charAt(index);
  18.             switch(currentSymbol){
  19.                 case 'a':
  20.                 case 'e':
  21.                 case 'i':
  22.                 case 'o':
  23.                 case 'u':
  24.                     count++;
  25.                     break;
  26.             }
  27.         }
  28.         System.out.println(count);
  29.     }
  30.  
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment