Advertisement
Guest User

12. Currency Converter

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