Hujifa

NSU Usrat Rifat

Feb 16th, 2022
941
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.61 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. class Main {
  4.  
  5.     public static void main(String[] args) {
  6.        
  7.         Scanner s = new Scanner(System.in);
  8.         String str = s.nextLine();
  9.        
  10.         System.out.println( countVowels(str) );
  11.     }
  12.    
  13.     public static int countVowels(String str){
  14.         int counter = 0;
  15.        
  16.         for (int i=0 ; i< str.length(); i++){
  17.             str = str.toLowerCase();
  18.             char ch = str.charAt(i);
  19.             if( ch == 'a'|| ch == 'e'|| ch == 'i' ||ch == 'o' ||ch == 'u'){
  20.                 counter++;
  21.             }
  22.         }
  23.        
  24.         return counter;
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment