Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace LettersChangeNumbersSecondTry
- {
- public class LettersChangeNumbersSecondTry
- {
- public static void Main()
- {
- string[] inputLine = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
- decimal totalSum = 0.0m;
- for (int currCombination = 0; currCombination < inputLine.Length; currCombination++)
- {
- string combination = inputLine[currCombination];
- StringBuilder numberToParse = new StringBuilder();
- for (int currNum = 1; currNum < combination.Length - 1; currNum++)
- {
- numberToParse.Append(combination[currNum]);
- }
- char firstLetter = combination[0];
- char lastLetter = combination[combination.Length - 1];
- decimal number = decimal.Parse(numberToParse.ToString());
- decimal currSum = 0.0m;
- if (char.IsUpper(firstLetter))
- {
- currSum = number / (firstLetter - 'A' + 1);
- }
- else
- {
- currSum = number * (firstLetter - 'a' + 1);
- }
- if (char.IsUpper(lastLetter))
- {
- currSum -= (lastLetter - 'A' + 1);
- }
- else
- {
- currSum += (lastLetter - 'a' + 1);
- }
- totalSum += currSum;
- }
- Console.WriteLine($"{totalSum:f2}");
- }
- }
- }
Add Comment
Please, Sign In to add comment