Advertisement
YavorGrancharov

Letters_Change_Numbers

Oct 28th, 2017
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.58 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace Letters_Change_Numbers
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             string[] input = Console.ReadLine()
  11.                 .Split(new char[] { ' ', '\t', '\n' },StringSplitOptions.RemoveEmptyEntries)
  12.                 .ToArray();
  13.  
  14.             double output = 0.0;
  15.             double result = 0.0;
  16.             double tempResult = 0.0;
  17.             double number = 0.0;
  18.             double indexFirst = 0.0;
  19.             double indexLast = 0.0;
  20.             string first = "";
  21.             string last = "";
  22.             string isNumber = "";
  23.             string temp = "";
  24.  
  25.             for (int i = 0; i < input.Length; i++)
  26.             {
  27.                 temp = input[i];
  28.                 for (int j = 0; j < temp.Length; j++)
  29.                 {
  30.                     first = temp.Substring(0,1);
  31.                     last = temp.Substring(temp.Length - 1, 1);
  32.                     isNumber = temp.Substring(1, temp.Length - 2);
  33.                     number = int.Parse(isNumber);                    
  34.                 }
  35.                 if (first.ToUpper() == first)
  36.                 {
  37.                     indexFirst = Convert.ToChar(first) - 64;
  38.                 }
  39.                 else
  40.                 {
  41.                     indexFirst = Convert.ToChar(first) - 96;
  42.                 }
  43.                 if (last.ToUpper() == last)
  44.                 {
  45.                     indexLast = Convert.ToChar(last) - 64;
  46.                 }
  47.                 else
  48.                 {
  49.                     indexLast = Convert.ToChar(last) - 96;
  50.                 }
  51.  
  52.                 if (first.ToUpper() == first && last.ToUpper() == last)
  53.                 {
  54.                     result = number / indexFirst;
  55.                     result -= indexLast;
  56.                 }
  57.                 else if (first.ToUpper() == first && last.ToLower() == last)
  58.                 {
  59.                     result = number / indexFirst;
  60.                     result += indexLast;
  61.                 }
  62.                 else if (first.ToLower() == first && last.ToUpper() == last)
  63.                 {
  64.                     result = number * indexFirst;
  65.                     result -= indexLast;
  66.                 }
  67.                 else if (first.ToLower() == first && last.ToLower() == last)
  68.                 {
  69.                     result = number * indexFirst;
  70.                     result += indexLast;
  71.                 }
  72.                 tempResult = result;
  73.                 output += tempResult;
  74.             }
  75.             Console.WriteLine("{0:F2}",output);
  76.         }
  77.     }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement