Advertisement
veronikaaa86

Currency Convertor C#

Oct 17th, 2017
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.57 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace Program
  7. {
  8.     class Program
  9.     {
  10.         static void Main()
  11.         {
  12.           var value = double.Parse(Console.ReadLine());  
  13.           var input = Console.ReadLine();// Enter BGN, USD, EUR or GBP currency
  14.             var output = Console.ReadLine();// Enter BGN, USD, EUR or GBP currency
  15.            
  16.             var bgn = 1.0;
  17.             var usd = 1.79549;
  18.             var eur = 1.95583;
  19.             var gbp = 2.53405;
  20.             switch (input)
  21.             {
  22.                 case "BGN":
  23.                     break;
  24.                 case "USD":
  25.                     value = value * usd;
  26.                     break;
  27.                 case "EUR":
  28.                     value = value * eur;
  29.                     break;
  30.                 case "GBP":
  31.                     value = value * gbp;
  32.                     break;
  33.                 default:
  34.                     break;
  35.             }
  36.             switch (output)
  37.             {
  38.                 case "BGN":
  39.                     value = value / bgn;
  40.                     break;
  41.                 case "USD":
  42.                     value = value / usd;
  43.                     break;
  44.                 case "EUR":
  45.                     value = value / eur;
  46.                     break;
  47.                 case "GBP":
  48.                     value = value / gbp;
  49.                     break;
  50.                 default:
  51.                     break;
  52.             }
  53.             Console.WriteLine(Math.Round(value, 2) + " " + output);
  54.         }
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement