fbinnzhivko

12.CurrencyConverter

Mar 7th, 2016
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.79 KB | None | 0 0
  1. using System;
  2.  
  3. class CurrencyConverter
  4. {
  5.     //    Напишете програма за конвертиране на парична сума от една валута в друга. Трябва да се поддържат следните валути: BGN, USD, EUR, GBP. Използвайте следните фиксирани валутни курсове:
  6.     //Курс    USD     EUR      GBP
  7.     //1 BGN 1.79549 1.95583 2.53405
  8.  
  9.     static void Main()
  10.     {
  11.         var USD = 1.79549;
  12.         var EUR = 1.95583;
  13.         var GBP = 2.53405;
  14.         var x = double.Parse(Console.ReadLine());
  15.         var firstCurency = Console.ReadLine();
  16.         var secondCerrency = Console.ReadLine();
  17.         var moneyInleva = 0.00;
  18.  
  19.         if (firstCurency == "USD") { moneyInleva = x * USD; }
  20.         else if (firstCurency == "EUR") { moneyInleva = x * EUR; }
  21.         else if (firstCurency == "GBP") { moneyInleva = x * GBP; }
  22.         else if (firstCurency == "BGN") { moneyInleva = x; }
  23.  
  24.  
  25.         var MoneyInWanted = 0.00;
  26.         if (secondCerrency == "USD") { MoneyInWanted = moneyInleva / USD; }
  27.         else if (secondCerrency == "EUR") { MoneyInWanted = moneyInleva / EUR; }
  28.         else if (secondCerrency == "GBP") { MoneyInWanted = moneyInleva / GBP; }
  29.         else if (secondCerrency == "BGN") { MoneyInWanted = moneyInleva; }
  30.  
  31.         Console.WriteLine("{0:0.00} {1}", MoneyInWanted, secondCerrency);
  32.  
  33.         //if (firstCurency == "USD" && secondCerrency == "BGN") { Console.WriteLine("{0:0.00} BGN", x * USD); }
  34.         //if (firstCurency == "USD" && secondCerrency == "EUR") { Console.WriteLine("{0:0.00} EUR", x * USD * EUR); }
  35.         //if (firstCurency == "USD" && secondCerrency == "GBP") { Console.WriteLine("{0:0.00} GBP", x * USD * GBP); }
  36.  
  37.         //if (firstCurency == "BGN" && secondCerrency == "USD") { Console.WriteLine("{0:0.00} USD", x / USD); }
  38.         //if (firstCurency == "BGN" && secondCerrency == "EUR") { Console.WriteLine("{0:0.00} EUR", x / EUR); }
  39.         //if (firstCurency == "BGN" && secondCerrency == "GBP") { Console.WriteLine("{0:0.00} GBP", x / GBP); }
  40.  
  41.         //if (firstCurency == "EUR" && secondCerrency == "BGN") { Console.WriteLine("{0:0.00} BGN", x * EUR); }
  42.         //if (firstCurency == "EUR" && secondCerrency == "USD") { Console.WriteLine("{0:0.00} USD", x * EUR * USD); }
  43.         //if (firstCurency == "EUR" && secondCerrency == "GBP") { Console.WriteLine("{0:0.00} GBP", x * EUR * GBP); }
  44.  
  45.         //if (firstCurency == "GBP" && secondCerrency == "BGN") { Console.WriteLine("{0:0.00} BGN", x / GBP); }
  46.         //if (firstCurency == "GBP" && secondCerrency == "EUR") { Console.WriteLine("{0:0.00} EUR", x / GBP / EUR); }
  47.         //if (firstCurency == "GBP" && secondCerrency == "USD") { Console.WriteLine("{0:0.00} GBP", x / USD / GBP); }
  48.  
  49.  
  50.     }
  51. }
Add Comment
Please, Sign In to add comment