Advertisement
koksibg

CurrencyConverter

Oct 5th, 2016
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.69 KB | None | 0 0
  1. using System;
  2.  
  3. namespace CurrencyConverter
  4. {
  5.     class CurrencyConverter
  6.     {
  7.         static void Main()
  8.         {
  9.             double OneUSDToBGN = 1.79549;
  10.             double OneEURToBGN = 1.95583;
  11.             double OneGBPToBGN = 2.53405;                      
  12.             double OneBGNToEUR = 1 / OneEURToBGN;
  13.             double OneBGNToUSD = 1 / OneUSDToBGN;
  14.             double OneBGNToGBP = 1 / OneGBPToBGN;
  15.             double OneUSDToEUR = OneUSDToBGN / OneEURToBGN;
  16.             double OneUSDToGBP = OneUSDToBGN / OneGBPToBGN;
  17.             double OneEURToUSD = OneEURToBGN / OneUSDToBGN;
  18.             double OneEURToGBP = OneEURToBGN / OneGBPToBGN;
  19.             double OneGBPToUSD = OneGBPToBGN / OneUSDToBGN;
  20.             double OneGBPToEUR = OneGBPToBGN / OneEURToBGN;
  21.             Console.Write("Amount to convert = ");
  22.             double Amount = double.Parse(Console.ReadLine());
  23.             Console.WriteLine("Select Imput Currency: BGN, USD, EUR or GBP");
  24.             string ImputCurrency = Console.ReadLine();
  25.             Console.WriteLine("Select Output Currency: BGN, USD, EUR or GBP");
  26.             string OutputCurrency = Console.ReadLine();
  27.             double BGNConvertToBGN = Amount;
  28.             double BGNConvertToUSD = Amount * OneBGNToUSD;
  29.             double BGNConvertToEUR = Amount * OneBGNToEUR;
  30.             double BGNConvertToGBP = Amount * OneBGNToGBP;
  31.             double USDConvertToUSD = Amount;
  32.             double USDConvertToEUR = Amount * OneUSDToEUR;
  33.             double USDConvertToGBP = Amount * OneUSDToGBP;
  34.             double USDConvertToBGN = Amount * OneUSDToBGN;
  35.             double EURConvertToEUR = Amount;
  36.             double EURConvertToBGN = Amount * OneEURToBGN;
  37.             double EURConvertToUSD = Amount * OneEURToUSD;
  38.             double EURConvertToGBP = Amount * OneEURToGBP;
  39.             double GBPConvertToGBP = Amount;
  40.             double GBPConvertToBGN = Amount * OneGBPToBGN;
  41.             double GBPConvertToUSD = Amount * OneGBPToUSD;
  42.             double GBPConvertToEUR = Amount * OneGBPToEUR;
  43.             while ((ImputCurrency == "BGN") && (OutputCurrency == "USD"))
  44.             {
  45.                 Console.WriteLine("converted currency = " + Math.Round(BGNConvertToUSD, 2));
  46.                 return;
  47.             }
  48.             while ((ImputCurrency == "BGN") && (OutputCurrency == "EUR"))
  49.             {
  50.                 Console.WriteLine("converted currency = " + Math.Round(BGNConvertToEUR, 2));
  51.                 return;
  52.             }
  53.             while ((ImputCurrency == "BGN") && (OutputCurrency == "GBP"))
  54.             {
  55.                 Console.WriteLine("converted currency = " + Math.Round(BGNConvertToGBP, 2));
  56.                 return;
  57.             }
  58.             while ((ImputCurrency == "USD") && (OutputCurrency == "BGN"))
  59.             {
  60.                 Console.WriteLine("converted currency = " + Math.Round(USDConvertToBGN, 2));
  61.                 return;
  62.             }
  63.             while ((ImputCurrency == "USD") && (OutputCurrency == "EUR"))
  64.             {
  65.                 Console.WriteLine("converted currency = " + Math.Round(USDConvertToEUR, 2));
  66.                 return;
  67.             }
  68.             while ((ImputCurrency == "USD") && (OutputCurrency == "GBP"))
  69.             {
  70.                 Console.WriteLine("converted currency = " + Math.Round(USDConvertToGBP, 2));
  71.                 return;
  72.             }
  73.             while ((ImputCurrency == "EUR") && (OutputCurrency == "BGN"))
  74.             {
  75.                 Console.WriteLine("converted currency = " + Math.Round(EURConvertToBGN, 2));
  76.                 return;
  77.             }
  78.             while ((ImputCurrency == "EUR") && (OutputCurrency == "USD"))
  79.             {
  80.                 Console.WriteLine("converted currency = " + Math.Round(EURConvertToUSD, 2));
  81.                 return;
  82.             }
  83.             while ((ImputCurrency == "EUR") && (OutputCurrency == "GBP"))
  84.             {
  85.                 Console.WriteLine("converted currency = " + Math.Round(EURConvertToGBP, 2));
  86.                 return;
  87.             }
  88.             while ((ImputCurrency == "GBP") && (OutputCurrency == "BGN"))
  89.             {
  90.                 Console.WriteLine("converted currency = " + Math.Round(GBPConvertToBGN, 2));
  91.                 return;
  92.             }
  93.             while ((ImputCurrency == "GBP") && (OutputCurrency == "EUR"))
  94.             {
  95.                 Console.WriteLine("converted currency = " + Math.Round(GBPConvertToEUR, 2));
  96.                 return;
  97.             }
  98.             while ((ImputCurrency == "GBP") && (OutputCurrency == "USD"))
  99.             {
  100.                 Console.WriteLine("converted currency = " + Math.Round(GBPConvertToUSD, 2));
  101.                 return;
  102.             }          
  103.         }
  104.     }
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement