Advertisement
Guest User

Untitled

a guest
Jul 10th, 2019
412
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.64 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 _6.MostPowerfulWord
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string word = Console.ReadLine();
  14.  
  15.             int bestScore = 0;
  16.             int currentScore = 0;
  17.             string mostPowerfulWord = "";
  18.             bool isVowel = false;
  19.  
  20.             while(word!="End of words")
  21.             {
  22.  
  23.                 for (int i = 0; i < word.Length; i++)
  24.                 {
  25.                     currentScore += word[i];
  26.                      
  27.                 }
  28.                 if (word[0] == 'a' || word[0] == 'A' || word[0] == 'e' || word[0] == 'E' || word[0] == 'i' || word[0] == 'I' || word[0] == 'o' || word[0] == 'O' || word[0] == 'u'
  29.                      || word[0] == 'U' || word[0] == 'y' || word[0] == 'Y')
  30.                 {
  31.                     currentScore *= word.Length;
  32.                 }
  33.                 else
  34.                 {
  35.                     currentScore =  currentScore/ word.Length;
  36.                 }
  37.  
  38.                 if (currentScore>bestScore)
  39.                 {
  40.                    
  41.                     mostPowerfulWord = word;
  42.                     bestScore = currentScore;
  43.                    
  44.                 }
  45.  
  46.  
  47.                 currentScore = 0;
  48.                 word = Console.ReadLine();
  49.                 if(word == "End of words")
  50.                 {
  51.                     Console.WriteLine($"The most powerful word is {mostPowerfulWord} - {bestScore}");
  52.                     break;
  53.                 }
  54.  
  55.             }
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement