Advertisement
simonradev

CurrencyConverterDictionary

Jul 22nd, 2017
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.86 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Globalization;
  7.  
  8. namespace CurrencyConverter
  9. {
  10.     class Program
  11.     {
  12.         static void Main()
  13.         {
  14.             double amountOfMoney = double.Parse(Console.ReadLine());
  15.             string fromCurrency = Console.ReadLine();
  16.             string toCurrency = Console.ReadLine();
  17.  
  18.             Dictionary<string, double> currencyValues = new Dictionary<string, double>
  19.             {
  20.                 ["BGN"] = 1.0,
  21.                 ["USD"] = 1.79549,
  22.                 ["EUR"] = 1.95583,
  23.                 ["GBP"] = 2.53405,
  24.             };
  25.  
  26.             double result = (currencyValues[fromCurrency] / currencyValues[toCurrency]) * amountOfMoney;
  27.  
  28.             Console.WriteLine($"{result:f2} {toCurrency}");
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement