bacco

* Конзолен междувалутен конвертор

Jan 21st, 2018
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.18 KB | None | 0 0
  1. using System;
  2.  
  3. namespace tESt
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.  
  10.             var money = double.Parse(Console.ReadLine());
  11.  
  12.             var initialCurrency = Console.ReadLine();
  13.             var targetCurrency = Console.ReadLine();
  14.  
  15.             const double USD = 1.79549;
  16.             const double EUR = 1.95583;
  17.             const double GBP = 2.53405;
  18.  
  19.             if (initialCurrency == "USD")
  20.             {
  21.                 money *= USD;
  22.             }
  23.             else if (initialCurrency == "EUR")
  24.             {
  25.                 money *= EUR;
  26.             }
  27.             else if (initialCurrency == "GBP")
  28.             {
  29.                 money *= GBP;
  30.             }
  31.  
  32.              if (targetCurrency == "USD")
  33.             {
  34.                 money /= USD;
  35.             }
  36.             else if (targetCurrency == "EUR")
  37.             {
  38.                 money /= EUR;
  39.             }
  40.             else if (targetCurrency == "GBP")
  41.             {
  42.                 money /= GBP;
  43.             }
  44.        
  45.              var result = Math.Round(money, 2);
  46.             Console.WriteLine(result + " " +targetCurrency);
  47.            
  48.  
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment