VelizarAvramov

09. Vowels Sum

Mar 22nd, 2017
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.12 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _09_VowelsSum
  8. {
  9.     class VowelsSum
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string text = Console.ReadLine();
  14.             int sum = 0;
  15.             //Console.WriteLine(text[0]);
  16.             for (int i = 0; i < text.Length; i++)
  17.             {
  18.                 //Console.WriteLine(text[i]);
  19.                 char currentLeter = text[i];
  20.                 if (text[i] == 'a')
  21.                 {
  22.                     sum += 1;
  23.                 }
  24.                 else if (text[i] == 'e')
  25.                 {
  26.                     sum += 2;
  27.                 }
  28.                 else if (text[i] == 'i')
  29.                 {
  30.                     sum += 3;
  31.                 }
  32.                 else if (text[i] == 'o')
  33.                 {
  34.                     sum += 4;
  35.                 }
  36.                 else if (text[i] == 'u')
  37.                 {
  38.                     sum += 5;
  39.                 }
  40.             }
  41.             Console.WriteLine("Vowels sum = " + sum);
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment