Advertisement
Monteso

Междувалутен конвертор

Sep 20th, 2017
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.88 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 moneyconverter
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Console.WriteLine("Сума:");
  14.             decimal amount = decimal.Parse(Console.ReadLine());
  15.             Console.WriteLine("Входна валута:");
  16.             string currencyOne = Console.ReadLine();
  17.             Console.WriteLine("Изходна валута:");
  18.             string currencyTwo = Console.ReadLine();
  19.             decimal convertionOne = new decimal();
  20.             decimal convertionTwo = new decimal();
  21.             decimal BGN = 1;
  22.             decimal USD = 1.79549m;
  23.             decimal EUR = 1.95583m;
  24.             decimal GBP = 2.53405m;
  25.             switch (currencyOne)
  26.             {
  27.                 case "BGN":
  28.                     convertionOne = amount * BGN;
  29.                     break;
  30.                 case "USD":
  31.                     convertionOne = amount * USD;
  32.                     break;
  33.                 case "EUR":
  34.                     convertionOne = amount * EUR;
  35.                     break;
  36.                 case "GBP":
  37.                     convertionOne = amount * GBP;
  38.                     break;
  39.             }
  40.             switch (currencyTwo)
  41.             {
  42.                 case "BGN":
  43.                     convertionTwo = convertionOne / BGN;
  44.                     break;
  45.                 case "USD":
  46.                     convertionTwo = convertionOne / USD;
  47.                     break;
  48.                 case "EUR":
  49.                     convertionTwo = convertionOne / EUR;
  50.                     break;
  51.                 case "GBP":
  52.                     convertionTwo = convertionOne / GBP;
  53.                     break;
  54.             }
  55.             Console.WriteLine(Math.Round(convertionTwo, 2));
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement