Advertisement
jkonova

Untitled

Aug 26th, 2021
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.55 KB | None | 0 0
  1. using System;
  2.  
  3. namespace TheMostPowerfulWord
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string currentWord = Console.ReadLine();
  10.  
  11.             int lengthOfTheMostPowerfulWord = int.MinValue;
  12.             string theMostPowerfulWord = "";
  13.  
  14.             while (currentWord != "End of words")
  15.             {
  16.                 int sumOfAllLetters = 0;
  17.  
  18.                 for (int i = 0; i < currentWord.Length; i++)
  19.                 {
  20.                     sumOfAllLetters += currentWord[i];
  21.                 }
  22.                 if (currentWord[0] == 'A' || currentWord[0] == 'a' || currentWord[0] == 'E' || currentWord[0] == 'e' || currentWord[0] == 'I' || currentWord[0] == 'i' || currentWord[0] == 'O' && currentWord[0] == 'o' || currentWord[0] == 'U' || currentWord[0] == 'u' || currentWord[0] == 'Y' || currentWord[0] == 'y')
  23.                 {
  24.                     sumOfAllLetters *= currentWord.Length;
  25.                 }
  26.                 else
  27.                 {
  28.                     sumOfAllLetters /= currentWord.Length;
  29.                     Math.Floor((double)sumOfAllLetters);
  30.                 }
  31.                 if (sumOfAllLetters > lengthOfTheMostPowerfulWord)
  32.                 {
  33.                     theMostPowerfulWord = currentWord;
  34.                     lengthOfTheMostPowerfulWord = sumOfAllLetters;
  35.                 }
  36.                 currentWord = Console.ReadLine();
  37.             }
  38.             Console.WriteLine($"The most powerful word is {theMostPowerfulWord} - {lengthOfTheMostPowerfulWord}");
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement