Advertisement
TodorovP

Currency Converter

Apr 21st, 2018
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.13 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_12
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {  
  13.             var currencyValue = double.Parse(Console.ReadLine());
  14.             var currencyInName = Console.ReadLine();
  15.             var currencyOutName = Console.ReadLine();
  16.            
  17.             byte indexIn = 0;
  18.             byte indexOut = 0;
  19.             string[] currencyName = {"BGN", "USD", "EUR", "GBP"};
  20.             double[] currencyRate = { 1d, 1.79549d, 1.95583d, 2.53405 };
  21.  
  22.             for (byte i = 0; i < currencyName.Length; i++)
  23.             {
  24.                 if (currencyInName == currencyName[i]) indexIn = i;
  25.                 if (currencyOutName == currencyName[i]) indexOut = i;              
  26.             }
  27.             var currencyOut = currencyValue * currencyRate[indexIn] /
  28.                 currencyRate[indexOut];
  29.            
  30.             Console.WriteLine("Currency value result = {0}",
  31.                                 Math.Round(currencyOut, 2));
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement