Advertisement
Guest User

Untitled

a guest
Jul 10th, 2019
584
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.66 KB | None | 0 0
  1. using System;
  2.  
  3. namespace The_Most_Powerful_Word
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string mostPowerfulWord = string.Empty;
  10.             int mostPowerfulWordPower = 0;
  11.             while (true)
  12.  
  13.             {
  14.                 string inputWord = Console.ReadLine();
  15.                 int currentWordPower = 0;
  16.                 int currentLetter = 0;
  17.                 if (inputWord == "End of words")
  18.                 {
  19.                     break;
  20.                 }
  21.  
  22.                 for (int i = 0; i < inputWord.Length; i++)
  23.                 {
  24.                      currentLetter = (int)inputWord[i];
  25.                      currentWordPower += currentLetter;
  26.                 }
  27.  
  28.                 if (inputWord[0] == 'a' || inputWord[0] == 'e' || inputWord[0] == 'y' ||
  29.                     inputWord[0] == 'i' || inputWord[0] == 'u' || inputWord[0] == 'o' ||
  30.                    inputWord[0] == 'A' || inputWord[0] == 'E' || inputWord[0] == 'Y' ||
  31.                     inputWord[0] == 'I' || inputWord[0] == 'U' || inputWord[0] == 'O')
  32.                 {
  33.                     currentWordPower *= inputWord.Length;
  34.                 }
  35.                 else
  36.                 {
  37.                     currentWordPower /= (inputWord.Length);
  38.                 }
  39.  
  40.                 if (currentWordPower > mostPowerfulWordPower)
  41.                 {
  42.                     mostPowerfulWordPower = currentWordPower;
  43.                     mostPowerfulWord = inputWord;
  44.                 }
  45.             }
  46.  
  47.             Console.WriteLine($"The most powerful word is {mostPowerfulWord} - {mostPowerfulWordPower:f0}");
  48.            
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement