Advertisement
Guest User

Decoding Exam Tsak

a guest
Feb 4th, 2015
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.28 KB | None | 0 0
  1. using System;
  2. class Program
  3. {
  4.     static void Main()
  5.     {
  6.         int salt = int.Parse(Console.ReadLine());
  7.         string text = Console.ReadLine();
  8.         int position = 0;
  9.  
  10.         foreach (char symbol in text)
  11.         {
  12.             if (symbol == '@')
  13.             {
  14.                 break;
  15.             }
  16.  
  17.             else if (symbol >= 'A' && symbol <= 'z')
  18.             {
  19.                 int letter = Convert.ToInt32(symbol);
  20.                 int letterSum = (letter * salt) + 1000;
  21.  
  22.                 double finalSumLetter = 0;
  23.  
  24.                 position++;
  25.                 if (position % 2 == 0)
  26.                 {
  27.                     finalSumLetter = letterSum * 100;
  28.                     Console.WriteLine(finalSumLetter);
  29.                 }
  30.                 else
  31.                 {
  32.                     finalSumLetter = letterSum / 100.00;
  33.                     Console.WriteLine("{0:F2}", finalSumLetter);
  34.                 }
  35.  
  36.             }
  37.  
  38.             else if (symbol == '0' || symbol == '1' || symbol == '2' || symbol == '3' || symbol == '4' || symbol == '5' || symbol == '6' || symbol == '7' || symbol == '8' || symbol == '9')
  39.             {
  40.                 int currentNumber = symbol + salt + 500;
  41.                 double finalSumNumber = 0;
  42.  
  43.                 position++;
  44.                 if (position % 2 == 0)
  45.                 {
  46.                     finalSumNumber = currentNumber * 100;
  47.                     Console.WriteLine(finalSumNumber);
  48.                 }
  49.  
  50.                 else
  51.                 {
  52.                     finalSumNumber = currentNumber / 100.00;
  53.                     Console.WriteLine("{0:F2}", finalSumNumber);
  54.                 }
  55.             }
  56.  
  57.             else
  58.             {
  59.                 int anyOtherSymbol = (Convert.ToInt32(symbol) - salt);
  60.                 double sumAnyOtherSymbol = 0;
  61.  
  62.                 position++;
  63.                 if (position % 2 == 0)
  64.                 {
  65.                     sumAnyOtherSymbol = anyOtherSymbol * 100;
  66.                     Console.WriteLine(sumAnyOtherSymbol);
  67.                 }
  68.  
  69.                 else
  70.                 {
  71.                     sumAnyOtherSymbol = anyOtherSymbol / 100.00;
  72.                     Console.WriteLine("{0:F2}", sumAnyOtherSymbol);
  73.                 }
  74.             }
  75.  
  76.         }
  77.     }
  78.  
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement