Advertisement
Guest User

Currency Converter

a guest
Sep 20th, 2017
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.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 Currency_Converter
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Console.Write("Input value to be converted: ");
  14.             var val = double.Parse(Console.ReadLine());
  15.  
  16.             Console.Write("Input currency (BGN, USD, EUR or GBP): ");
  17.             string inCurr = (Console.ReadLine());
  18.  
  19.             Console.Write("Output currency (BGN, USD, EUR or GBP): ");
  20.             string outCurr = (Console.ReadLine());
  21.  
  22.             //Convert to BGN
  23.  
  24.             double midConvert = 1;
  25.  
  26.             if (inCurr == "USD")
  27.             {
  28.                 midConvert = 1.79549 * val;
  29.             }
  30.             if (inCurr == "EUR")
  31.             {
  32.                 midConvert = 1.95583 * val;
  33.             }
  34.             if (inCurr == "GBP")
  35.             {
  36.                 midConvert = 2.53405 * val;
  37.             }
  38.             if (inCurr == "BGN")
  39.             {
  40.                 midConvert = 1 * val;
  41.             }
  42.  
  43.             double output = 1;
  44.  
  45.             if (outCurr == "USD")
  46.             {
  47.                 output = midConvert / 1.79549;
  48.             }
  49.             if (outCurr == "EUR")
  50.             {
  51.                 output = midConvert / 1.95583;
  52.             }
  53.             if (outCurr == "GBP")
  54.             {
  55.                 output = midConvert / 2.53405;
  56.             }
  57.             if (outCurr == "BGN")
  58.             {
  59.                 output = midConvert / 1;
  60.             }
  61.  
  62.             Console.WriteLine(Math.Round(output, 2) + " "+ outCurr);
  63.         }
  64.     }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement