WindFell

Dictionary Variant

May 20th, 2018
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.63 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. class CurrencyConverter
  5. {
  6.     static void Main(string[] args)
  7.     {
  8.         Dictionary<string, decimal> curencies = new Dictionary<string, decimal>();
  9.         curencies.Add("BGN", 1m);
  10.         curencies.Add("USD", 1.79549m);
  11.         curencies.Add("EUR", 1.95583m);
  12.         curencies.Add("GBP", 2.53405m);
  13.  
  14.         decimal amount = decimal.Parse(Console.ReadLine());
  15.         string inputCurrency = Console.ReadLine();
  16.         string outputCurrency = Console.ReadLine();
  17.  
  18.         amount *= curencies[inputCurrency];
  19.         amount /= curencies[outputCurrency];
  20.  
  21.         string result = $"{amount:F2} {outputCurrency}";
  22.         Console.WriteLine(result);
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment