Advertisement
Somo4k

06. MostPowerfullWord

Jun 15th, 2021
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. using System;
  2.  
  3. namespace P06_TheMostPowerfulWord
  4. {
  5. class P06_TheMostPowerfulWord
  6. {
  7. static void Main(string[] args)
  8. {
  9. string mostPowerfulWord = "";
  10. double maxPower = 0;
  11.  
  12. string input = "";
  13. while ("End of words" != (input = Console.ReadLine()))
  14. {
  15. double inputSum = 0;
  16. for (int i = 0; i < input.Length; i++)
  17. {
  18. inputSum += input[i];
  19. }
  20.  
  21. int numLength = input.Length;
  22. string input2 = input.ToLower();
  23. if (input2[0] == 'a'
  24. || input2[0] == 'e'
  25. || input2[0] == 'i'
  26. || input2[0] == 'o'
  27. || input2[0] == 'u'
  28. || input2[0] == 'y')
  29. {
  30. inputSum = inputSum * numLength;
  31. }
  32. else
  33. {
  34. inputSum = Math.Floor(inputSum / numLength);
  35. }
  36.  
  37. if (inputSum > maxPower)
  38. {
  39. maxPower = inputSum;
  40. mostPowerfulWord = input;
  41. }
  42. }
  43.  
  44. Console.WriteLine($"The most powerful word is {mostPowerfulWord} - {maxPower}");
  45. }
  46. }
  47. }
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement