Advertisement
rado8506

12. Currency Converter

Jan 20th, 2018
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.26 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 ConsoleApp5
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             decimal currency = decimal.Parse(Console.ReadLine());
  14.             string inputCurrency = Console.ReadLine().ToUpper();
  15.             string outputCurrency = Console.ReadLine().ToUpper();
  16.  
  17.             if (inputCurrency == "USD")
  18.             {
  19.                 currency = currency * 1.79549m;
  20.             }
  21.             else if (inputCurrency == "EUR")
  22.             {
  23.                 currency = currency * 1.95583m;
  24.             }
  25.             else if (inputCurrency == "GBP")
  26.             {
  27.                 currency = currency * 2.53405m;
  28.             }
  29.  
  30.             if (outputCurrency == "USD")
  31.             {
  32.                 currency = currency / 1.79549m;
  33.             }
  34.             else if (outputCurrency == "EUR")
  35.             {
  36.                 currency = currency / 1.95583m;
  37.             }
  38.             else if (outputCurrency == "GBP")
  39.             {
  40.                 currency = currency / 2.53405m;
  41.             }
  42.  
  43.             Console.WriteLine("{0} {1}", Math.Round(currency, 2), outputCurrency.ToUpper());
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement