Advertisement
plamen27

Currency Converter with switches

Jun 24th, 2016
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 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 Currency_Converter_with_switches
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13.  
  14. decimal amount = decimal.Parse(Console.ReadLine());
  15. string currencyOne = Console.ReadLine();
  16. string currencyTwo = Console.ReadLine();
  17. decimal convertionOne = new decimal();
  18. decimal convertionTwo = new decimal();
  19. decimal BGN = 1;
  20. decimal USD = 1.79549m;
  21. decimal EUR = 1.95583m;
  22. decimal GBP = 2.53405m;
  23. switch (currencyOne)
  24. {
  25. case "BGN":
  26. convertionOne = amount * BGN;
  27. break;
  28. case "USD":
  29. convertionOne = amount * USD;
  30. break;
  31. case "EUR":
  32. convertionOne = amount * EUR;
  33. break;
  34. case "GBP":
  35. convertionOne = amount * GBP;
  36. break;
  37. }
  38. switch (currencyTwo)
  39. {
  40. case "BGN":
  41. convertionTwo = convertionOne / BGN;
  42. break;
  43. case "USD":
  44. convertionTwo = convertionOne / USD;
  45. break;
  46. case "EUR":
  47. convertionTwo = convertionOne / EUR;
  48. break;
  49. case "GBP":
  50. convertionTwo = convertionOne / GBP;
  51. break;
  52. }
  53. Console.WriteLine(Math.Round(convertionTwo, 2));
  54.  
  55. }
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement