TodorovP

Currency_Converter

Jan 20th, 2018
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.71 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.             Console.Write("Currency value = "); // Поставя се под коментар за
  14.                                            // тестване в Judge (изключва се)
  15.             var currencyValue = double.Parse(Console.ReadLine());
  16.             Console.Write("Currency inpit name = "); // Поставя се под коментар за
  17.                                                 // тестване в Judge (изключва се)
  18.             var currencyInName = Console.ReadLine();
  19.             Console.Write("Currency outpit name = "); // Поставя се под коментар за
  20.                                                 // тестване в Judge (изключва се)
  21.             var currencyOutName = Console.ReadLine();
  22.  
  23.             byte indexIn = 0;
  24.             byte indexOut = 0;
  25.             string[] currencyName = {"BGN", "USD", "EUR", "GBP"};
  26.             double[] currencyRate = { 1d, 1.79549d, 1.95583d, 2.53405 };
  27.  
  28.             for (byte i = 0; i < currencyName.Length; i++)
  29.             {
  30.                 if (currencyInName == currencyName[i]) indexIn = i;
  31.                 if (currencyOutName == currencyName[i]) indexOut = i;              
  32.             }
  33.             var currencyOut = currencyValue * currencyRate[indexIn] /
  34.                 currencyRate[indexOut];
  35.            
  36.             Console.WriteLine("Currency value result = {0}",
  37.                                 Math.Round(currencyOut, 2));
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment