Advertisement
Guest User

Untitled

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