Advertisement
MZlatev

Untitled

Oct 18th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _2._VowelsCount
  4. {
  5. class VowelsCount
  6. {
  7. static void Main()
  8. {
  9. string word = Console.ReadLine();
  10.  
  11. string output = GetVowelsCount(word);
  12. Console.WriteLine(output);
  13.  
  14. }
  15.  
  16. static string GetVowelsCount(string word)
  17. {
  18. int count = 0;
  19.  
  20. for (int i = 0; i < word.Length; i++)
  21. {
  22. char currentLetter = word[i];
  23.  
  24. bool conditionA = currentLetter == 'a' || currentLetter == 'A';
  25. bool conditionE = currentLetter == 'e' || currentLetter == 'E';
  26. bool conditionI = currentLetter == 'i' || currentLetter == 'I';
  27. bool conditionO = currentLetter == 'o' || currentLetter == 'O';
  28. bool conditionU = currentLetter == 'u' || currentLetter == 'U';
  29. bool conditionY = currentLetter == 'y' || currentLetter == 'Y';
  30.  
  31.  
  32.  
  33. if (conditionA || conditionE || conditionI || conditionO || conditionU || conditionY)
  34. {
  35. count++;
  36. }
  37. }
  38.  
  39. string counter = count.ToString();
  40. return counter;
  41. }
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement