VelizarAvramov

12. Currency Converter

Mar 19th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.64 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 _14_CurrencyConverter
  8. {
  9.     class CurrencyConverter
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             double costToConvert = double.Parse(Console.ReadLine());
  14.             string firstCurrency = Console.ReadLine();
  15.             string secondCurrency = Console.ReadLine();
  16.  
  17.             double bgn = 1.0;
  18.             double usd = 1.79549;
  19.             double eur = 1.95583;
  20.             double gbp = 2.53405;
  21.  
  22.             if (firstCurrency == "BGN")
  23.             {
  24.                 if (secondCurrency == "USD")
  25.                 {
  26.                     Console.WriteLine("{0:f2}" , costToConvert / usd);
  27.                 }
  28.                 else if (secondCurrency == "EUR")
  29.                 {
  30.                     Console.WriteLine("{0:f2}" , costToConvert / eur);
  31.                 }
  32.                 else if (secondCurrency == "GBP")
  33.                 {
  34.                     Console.WriteLine("{0:f2}" , costToConvert / gbp);
  35.                 }
  36.                 else if ((secondCurrency != "USD") && (secondCurrency != "EUR") && (secondCurrency != "GBP"))
  37.                 {
  38.                     Console.WriteLine("Wrong currency");
  39.                 }
  40.             }
  41.             else if (firstCurrency == "USD")
  42.             {
  43.                 if (secondCurrency == "BGN")
  44.                 {
  45.                     Console.WriteLine("{0:f2}" , costToConvert * usd);
  46.                 }
  47.                 else if (secondCurrency == "EUR")
  48.                 {
  49.                     Console.WriteLine("{0:f2}" , costToConvert * usd);
  50.                 }
  51.                 else if (secondCurrency == "GBP")
  52.                 {
  53.                     Console.WriteLine("{0:f2}" , costToConvert * usd);
  54.                 }
  55.                 else if ((secondCurrency != "BGN") && (secondCurrency != "EUR") && (secondCurrency != "GBP"))
  56.                 {
  57.                     Console.WriteLine("Wrong currency");
  58.                 }
  59.             }
  60.             else if (firstCurrency == "EUR")
  61.             {
  62.                 if (secondCurrency == "BGN")
  63.                 {
  64.                     Console.WriteLine("{0:f2}" , costToConvert * eur);
  65.                 }
  66.                 else if (secondCurrency == "USD")
  67.                 {
  68.                     Console.WriteLine("{0:f2}" , costToConvert * usd);
  69.                 }
  70.                 else if (secondCurrency == "GBR")
  71.                 {
  72.                     Console.WriteLine("{0:f2}" , costToConvert * gbp);
  73.                 }
  74.                 else if ((secondCurrency != "BGN") && (secondCurrency != "USD") && (secondCurrency != "GBP"))
  75.                 {
  76.                     Console.WriteLine("Wrong currency");
  77.                 }
  78.             }
  79.             else if (firstCurrency == "GBP")
  80.             {
  81.                 if (secondCurrency == "BGN")
  82.                 {
  83.                     Console.WriteLine("{0:f2}" , costToConvert * gbp);
  84.                 }
  85.                 else if (secondCurrency == "USD")
  86.                 {
  87.                     Console.WriteLine("{0:f2}" , costToConvert * usd);
  88.                 }
  89.                 else if (secondCurrency == "EUR")
  90.                 {
  91.                     Console.WriteLine("{0:f2}", costToConvert * eur);
  92.                 }
  93.                 else if ((secondCurrency != "BGN") && (secondCurrency != "USD") && (secondCurrency != "EUR"))
  94.                 {
  95.                     Console.WriteLine("Wrong currency");
  96.                 }
  97.             }
  98.             else
  99.             {
  100.                 Console.WriteLine("Wrong curency");
  101.             }
  102.         }
  103.     }
  104. }
Add Comment
Please, Sign In to add comment