pavlinpetkov88

CurrencyConverter

Oct 26th, 2016
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.11 KB | None | 0 0
  1. using System;
  2.  
  3. class CurrencyConverter
  4. {
  5.     static void Main()
  6.     {
  7.         decimal value = decimal.Parse(Console.ReadLine());
  8.  
  9.         var currency1 = Console.ReadLine();
  10.         var currency2 = Console.ReadLine();
  11.  
  12.         decimal rate1 = 0.0m;
  13.         decimal rate2 = 0.0m;
  14.  
  15.         if (currency1 == "BGN")
  16.         {
  17.             rate1 = 1m;
  18.         }
  19.         else if (currency1 == "EUR")
  20.         {
  21.             rate1 = 1.95583m;
  22.         }
  23.         else if (currency1 == "USD")
  24.         {
  25.             rate1 = 1.79549m;
  26.         }
  27.         else if (currency1 == "GBP")
  28.         {
  29.             rate1 = 2.53405m;
  30.         }
  31.  
  32.         if (currency2 == "BGN")
  33.         {
  34.             rate2 = 1m;
  35.         }
  36.         else if (currency2 == "EUR")
  37.         {
  38.             rate2 = 1.95583m;
  39.         }
  40.         else if (currency2 == "USD")
  41.         {
  42.             rate2 = 1.79549m;
  43.         }
  44.         else if (currency2 == "GBP")
  45.         {
  46.             rate2 = 2.53405m;
  47.         }
  48.  
  49.         decimal sum = value * (rate1 / rate2);
  50.         Console.WriteLine(Math.Round(sum, 2) + " " + currency2);
  51.  
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment