Advertisement
Guest User

Currency Converter

a guest
Oct 14th, 2018
1,133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.85 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 CurrencyConverter
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. double amountToConvert = double.Parse(Console.ReadLine());
  14. string incomingCurrency = Console.ReadLine();
  15. string sourceCurrency = Console.ReadLine();
  16. double USD = 1.79549;
  17. double EUR = 1.95583;
  18. double GBP = 2.53405;
  19.  
  20. double currentCurrency = 0;
  21. double totalSum = 0;
  22. if (incomingCurrency == "BGN")
  23. {
  24. currentCurrency = amountToConvert;
  25. if (sourceCurrency == "USD")
  26. {
  27. totalSum = currentCurrency / USD;
  28. }
  29. else if (sourceCurrency == "EUR")
  30. {
  31. totalSum = currentCurrency / EUR;
  32. }
  33. else if (sourceCurrency == "GBP")
  34. {
  35. totalSum = currentCurrency / GBP;
  36. }
  37. }
  38. else if (incomingCurrency == "USD")
  39. {
  40. currentCurrency = amountToConvert * USD;
  41. if (sourceCurrency == "BGN")
  42. {
  43. totalSum = currentCurrency;
  44. }
  45. else if (sourceCurrency == "EUR")
  46. {
  47. totalSum = currentCurrency / EUR;
  48. }
  49. else if (sourceCurrency == "GBP")
  50. {
  51. totalSum = currentCurrency / GBP;
  52. }
  53. }
  54. else if (incomingCurrency == "EUR")
  55. {
  56. currentCurrency = amountToConvert * EUR;
  57. if (sourceCurrency == "BGN")
  58. {
  59. totalSum = currentCurrency;
  60. }
  61. else if (sourceCurrency == "USD")
  62. {
  63. totalSum = currentCurrency / USD;
  64. }
  65. else if (sourceCurrency == "GBP")
  66. {
  67. totalSum = currentCurrency / GBP;
  68. }
  69. }
  70. else if (incomingCurrency == "GBP")
  71. {
  72. currentCurrency = amountToConvert * GBP;
  73. if (sourceCurrency == "BGN")
  74. {
  75. totalSum = currentCurrency;
  76. }
  77. else if (sourceCurrency == "USD")
  78. {
  79. totalSum = currentCurrency / USD;
  80. }
  81. else if (sourceCurrency == "EUR")
  82. {
  83. totalSum = currentCurrency / EUR;
  84. }
  85. }
  86. Console.WriteLine($"{totalSum:F2} {sourceCurrency}");
  87. }
  88. }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement