Advertisement
ivanov_ivan

CurrencyConverter

Jan 24th, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.69 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Globalization;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace Test
  9. {
  10.     class CurrencyConverter
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             decimal BGN = 1.0M;
  15.             decimal USD = 1.79549M;
  16.             decimal EUR = 1.95583M;
  17.             decimal GBP = 2.53405M;
  18.             decimal value = decimal.Parse(Console.ReadLine());
  19.             string inputCurrency = Console.ReadLine();
  20.             string outputCurrency = Console.ReadLine();
  21.  
  22.             switch(inputCurrency)                              
  23.             {
  24.                 case "BGN":
  25.                     break;
  26.                 case "USD":
  27.                     value = ( value * USD );
  28.                     break;
  29.                 case "EUR":
  30.                     value = ( value * EUR );
  31.                     break;
  32.                 case "GBP":
  33.                     value = ( value * GBP );
  34.                     break;
  35.                 default:
  36.                     break;
  37.             }
  38.             switch(outputCurrency)                          
  39.             {
  40.                 case "BGN":
  41.                     value = value / BGN;
  42.                     break;
  43.                 case "USD":
  44.                     value = value / USD;
  45.                     break;
  46.                 case "EUR":
  47.                     value = value / EUR;
  48.                     break;
  49.                 case "GBP":
  50.                     value = value / GBP;
  51.                     break;
  52.                 default:
  53.                     break;
  54.             }
  55.             Console.WriteLine("{0:F2} {1}", value, outputCurrency);
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement