Advertisement
Guest User

Untitled

a guest
Oct 24th, 2016
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.92 KB | None | 0 0
  1. using System;
  2.  
  3.  
  4.     class CurrencyConverter
  5. {
  6.  
  7.        
  8.         static void Main()
  9.         {
  10.             var amount = double.Parse(Console.ReadLine());
  11.             string firstCurrency = Console.ReadLine();
  12.             string secondCurrency = Console.ReadLine();
  13.  
  14.             double value1 = CheckCurrency(firstCurrency);
  15.             double value2 = CheckCurrency(secondCurrency);
  16.  
  17.             double result = (value1 / value2) * amount;
  18.             Console.WriteLine("{0} {1}",Math.Round(result, 2),secondCurrency);
  19.  
  20.  
  21.         }
  22.     static double CheckCurrency(string curr)
  23.     {
  24.         switch (curr)
  25.         {
  26.             case "BGN":
  27.                 return 1;
  28.  
  29.             case "USD":
  30.                 return 1.79549;
  31.  
  32.             case "EUR":
  33.                 return 1.95583;
  34.             case "GBP":
  35.                 return 2.53405;
  36.  
  37.             default:
  38.                 return 1;
  39.  
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement