Advertisement
Atanasov91

CurrencyConverter

Jan 16th, 2018
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.55 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 _12.CurrencyConverter
  8. {
  9.     class CurrencyConverter
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             double money = double.Parse(Console.ReadLine());
  14.             string firstCurrency = Console.ReadLine();
  15.             string secondCurrency = Console.ReadLine();
  16.             double firstValue = 0.0;
  17.             double secondValue = 0.0;
  18.  
  19.             if (firstCurrency == "BGN")
  20.             {
  21.                 firstValue = 1.0;
  22.             }
  23.             else if (firstCurrency == "USD")
  24.             {
  25.                 firstValue = 1.79549;
  26.             }
  27.             else if (firstCurrency == "EUR")
  28.             {
  29.                 firstValue = 1.95583;
  30.             }
  31.             else if (firstCurrency == "GBP")
  32.             {
  33.                 firstValue = 2.53405;
  34.             }
  35.  
  36.  
  37.             if (secondCurrency == "BGN")
  38.             {
  39.                 secondValue = 1.0;
  40.             }
  41.             else if (secondCurrency == "USD")
  42.             {
  43.                 secondValue = 1.79549;
  44.             }
  45.             else if (secondCurrency == "EUR")
  46.             {
  47.                 secondValue = 1.95583;
  48.             }
  49.             else if (secondCurrency == "GBP")
  50.             {
  51.                 secondValue = 2.53405;
  52.             }
  53.  
  54.             double result = money * (firstValue / secondValue);
  55.  
  56.             Console.WriteLine("{0} {1}", Math.Round(result, 2), secondCurrency);
  57.         }
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement