viraco4a

CurrencyFixings

Jan 13th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 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.  
  7. namespace task_02
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. decimal inputSum = decimal.Parse(Console.ReadLine());
  14. string vhodenCurr = Console.ReadLine();
  15. string izhodenCurr = Console.ReadLine();
  16. Dictionary<string, decimal> Fixings = new Dictionary<string, decimal>();
  17. Fixings["USD"] = 1.79549m;
  18. Fixings["EUR"] = 1.95583m;
  19. Fixings["GBP"] = 2.53405m;
  20. Fixings["BGN"] = 1.0m;
  21. decimal first = 0;
  22. decimal second = 0;
  23. foreach (var item in Fixings)
  24. {
  25. KeyValuePair<string, decimal> kvp = item;
  26. if (kvp.Key == vhodenCurr)
  27. {
  28. first = kvp.Value;
  29. }
  30. if (kvp.Key == izhodenCurr)
  31. {
  32. second = kvp.Value;
  33. }
  34. }
  35. decimal result = inputSum * (first / second);
  36. Console.WriteLine($"{result:f2} {izhodenCurr}");
  37. }
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment