Advertisement
Qrist

Sum of Vowels

Apr 17th, 2020
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.71 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5.     public static void Main(string[] args)
  6.     {
  7.         string text = Console.ReadLine();
  8.         int sum = 0;
  9.         for (int i = 0; i < text.Length; i++)
  10.         {
  11.             if(text[i]=='a')
  12.             {
  13.                 sum += 1;
  14.             }
  15.             else if(text[i]=='e')
  16.             {
  17.                 sum += 2;
  18.             }
  19.             else if (text[i] == 'i')
  20.             {
  21.                 sum += 3;
  22.             }
  23.             else if (text[i] == 'o')
  24.             {
  25.                 sum += 4;
  26.             }
  27.             else if (text[i] == 'u')
  28.             {
  29.                 sum += 5;
  30.             }
  31.         }
  32.         Console.WriteLine(sum);
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement