Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace TheMostPowerfulWord
- {
- class Program
- {
- static void Main(string[] args)
- {
- string word = Console.ReadLine();
- string strong = "";
- double total = 0;
- while (word != "End of words")
- {
- double sum = 0;
- for (int i = 0; i <= word.Length - 1; i++)
- {
- sum += word[i];
- }
- switch (word[0].ToLower())
- {
- case 'a':
- case 'e':
- case 'i':
- case 'o':
- case 'u':
- case 'y':
- sum *= word.Length;
- break;
- default:
- sum /= word.Length;
- break;
- }
- if (sum > total)
- {
- strong = word;
- total = sum;
- }
- word = Console.ReadLine();
- }
- Console.WriteLine($"The most powerful word is {strong} - {Math.Floor(total)}");
- }
- }
- }
Add Comment
Please, Sign In to add comment