gospod1978

Methods-Ex\Vowels Count

Oct 13th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.13 KB | None | 0 0
  1. using System;
  2.  
  3. namespace methods_exerci
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string text = Console.ReadLine().ToLower();
  10.             Console.WriteLine(Vowels(text));
  11.  
  12.         }
  13.  
  14.         static int Vowels (string text)
  15.         {
  16.             int vowels = 0;
  17.  
  18.             for (int i = 0; i < text.Length; i++)
  19.             {
  20.                 char word = text[i];
  21.  
  22.                 switch(word)
  23.                 {
  24.                     case 'a':
  25.                         vowels++;
  26.                         break;
  27.                     case 'o':
  28.                         vowels++;
  29.                         break;
  30.                     case 'e':
  31.                         vowels++;
  32.                         break;
  33.                     case 'i':
  34.                         vowels++;
  35.                         break;
  36.                     case 'u':
  37.                         vowels++;
  38.                         break;
  39.                     case 'y':
  40.                         vowels++;
  41.                         break;
  42.                 }
  43.             }
  44.  
  45.             return vowels;
  46.         }
  47.     }
  48. }
Add Comment
Please, Sign In to add comment