Advertisement
jwrbg

Vowels

Feb 19th, 2020
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1. package com;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Vowels
  6. {
  7.   public static void main(String[] args)
  8.   {
  9.     Scanner scanner = new Scanner(System.in);
  10.     String input = scanner.nextLine();
  11.     String checkWord = input.toLowerCase();
  12.     char[] vowels = {'a', 'e', 'y', 'u', 'i', 'o'};
  13.     int countOfVowels = 0;
  14.     for (int i = 0; i < checkWord.length(); i++) {
  15.       for (int j = 0; j < vowels.length; j++) {
  16.         if (vowels[j] == checkWord.charAt(i)) {
  17.           countOfVowels++;
  18.         }
  19.  
  20.       }
  21.     }
  22.     System.out.println(countOfVowels);
  23.  
  24.   }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement