Advertisement
MZlatev

Untitled

Nov 21st, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _8._LettersChangeNumbers
  6. {
  7. class LettersChangeNumbers
  8. {
  9. static void Main()
  10. {
  11. string input = Console.ReadLine();
  12.  
  13. string[] splitedInput = input
  14. .Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
  15.  
  16. double totalSum = 0;
  17.  
  18. for (int i = 0; i < splitedInput.Length; i++)
  19. {
  20. //char firstLetter = splitedInput[i][0];
  21. string currentInput = splitedInput[i];
  22. char firstLetter = currentInput[0];
  23. char lastLetter = currentInput[currentInput.Length - 1];
  24.  
  25. double digit = double.Parse(currentInput.Substring(1, currentInput.Length - 2));
  26.  
  27. if (char.IsUpper(firstLetter))
  28. {
  29. digit /= firstLetter - 'A' + 1;
  30. }
  31.  
  32. else
  33. {
  34. digit *= firstLetter - 'a' + 1;
  35. }
  36.  
  37. if (char.IsUpper(lastLetter))
  38. {
  39. digit -= lastLetter - 'A' + 1;
  40. }
  41.  
  42. else
  43. {
  44. digit += lastLetter - 'a' + 1;
  45. }
  46.  
  47. totalSum += digit;
  48. }
  49.  
  50. Console.WriteLine(totalSum.ToString("f2"));
  51. }
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement