Advertisement
MARINA_GREBENAROVA

VowelsCount

Aug 22nd, 2022
889
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.69 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace VowelsCount
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             string word = Console.ReadLine();
  11.  
  12.             int vowelCount = GetVowelsCount(word);
  13.             Console.WriteLine(vowelCount);
  14.         }
  15.  
  16.         static int GetVowelsCount(string word)
  17.         {
  18.             char[] vowel = new char[] { 'a', 'e', 'i', 'o', 'u' };
  19.  
  20.             int vowelCount = 0;
  21.  
  22.             foreach (char ch in word.ToLower())
  23.             {
  24.                 if (vowel.Contains(ch))
  25.                 {
  26.                     vowelCount++;
  27.                 }
  28.             }
  29.             return vowelCount;
  30.         }
  31.     }
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement