Advertisement
WindFell

Switch Variant

May 20th, 2018
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.70 KB | None | 0 0
  1. using System;
  2.  
  3. class CurrencyConverter
  4. {
  5.     static void Main(string[] args)
  6.     {
  7.         decimal amount = decimal.Parse(Console.ReadLine());
  8.         string inputCurrency = Console.ReadLine();
  9.         string outputCurrency = Console.ReadLine();
  10.  
  11.         switch (inputCurrency)
  12.         {
  13.             case "USD":
  14.                 amount *= 1.79549m;
  15.                 break;
  16.             case "EUR":
  17.                 amount *= 1.95583m;
  18.                 break;
  19.             case "GBP":
  20.                 amount *= 2.53405m;
  21.                 break;
  22.         }
  23.  
  24.         switch (outputCurrency)
  25.         {
  26.             case "USD":
  27.                 amount /= 1.79549m;
  28.                 break;
  29.             case "EUR":
  30.                 amount /= 1.95583m;
  31.                 break;
  32.             case "GBP":
  33.                 amount /= 2.53405m;
  34.                 break;
  35.         }
  36.  
  37.         string result = $"{amount:F2} {outputCurrency}";
  38.         Console.WriteLine(result);
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement