Stradjazz

Currency Converter with if, else if

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