Advertisement
ivanov_ivan

CurrencyConverter

Jan 24th, 2016
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.28 KB | None | 0 0
  1. using System;
  2. class CurrencyConverter
  3. {
  4.     static void Main(string[] args)
  5.     {
  6.         decimal BGN = 1.0M;
  7.         decimal USD = 1.79549M;
  8.         decimal EUR = 1.95583M;
  9.         decimal GBP = 2.53405M;
  10.         decimal inputValue = decimal.Parse(Console.ReadLine());
  11.         string inputCurrency = Console.ReadLine();
  12.         string outputCurrency = Console.ReadLine();
  13.  
  14.         switch(inputCurrency)
  15.         {
  16.             case "BGN":
  17.                 break;
  18.             case "USD":
  19.                 inputValue = inputValue * USD;
  20.                 break;
  21.             case "EUR":
  22.                 inputValue = inputValue * EUR;
  23.                 break;
  24.             case "GBP":
  25.                 inputValue = inputValue * GBP;
  26.                 break;
  27.         }
  28.  
  29.         switch(outputCurrency)
  30.         {
  31.             case "BGN":
  32.                 inputValue = inputValue / BGN;
  33.                 break;
  34.             case "USD":
  35.                 inputValue = inputValue / USD;
  36.                 break;
  37.             case "EUR":
  38.                 inputValue = inputValue / EUR;
  39.                 break;
  40.             case "GBP":
  41.                 inputValue = inputValue / GBP;
  42.                 break;
  43.         }
  44.  
  45.         Console.WriteLine("{0:F2} {1}" , inputValue , outputCurrency);
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement