Advertisement
Guest User

Untitled

a guest
Oct 18th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.44 KB | None | 0 0
  1. using System;
  2. //Problem 14: Currency Converter
  3. class CurrencyConverter
  4. {
  5.     static void Main(string[] args)
  6.     {
  7.         decimal amount = decimal.Parse(Console.ReadLine());
  8.         string currencyOne = Console.ReadLine();
  9.         string currencyTwo = Console.ReadLine();
  10.         decimal convertionOne = new decimal();
  11.         decimal convertionTwo = new decimal();
  12.         decimal BGN = 1;
  13.         decimal USD = 1.79549m;
  14.         decimal EUR = 1.95583m;
  15.         decimal GBP = 2.53405m;
  16.         switch (currencyOne)
  17.         {
  18.             case "BGN" :
  19.                 convertionOne = amount * BGN;
  20.                 break;
  21.             case "USD":
  22.                 convertionOne = amount * USD;
  23.                 break;
  24.             case "EUR":
  25.                 convertionOne = amount * EUR;
  26.                 break;
  27.             case "GBP":
  28.                 convertionOne = amount * GBP;
  29.                 break;
  30.         }
  31.         switch (currencyTwo)
  32.         {
  33.             case "BGN":
  34.                 convertionTwo = convertionOne / BGN;
  35.                 break;
  36.             case "USD":
  37.                 convertionTwo = convertionOne / USD;
  38.                 break;
  39.             case "EUR":
  40.                 convertionTwo = convertionOne / EUR;
  41.                 break;
  42.             case "GBP":
  43.                 convertionTwo = convertionOne / GBP;
  44.                 break;
  45.         }
  46.         Console.WriteLine(Math.Round(convertionTwo, 2));
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement