LusienGG

[C#]12. Currency Converter

Dec 21st, 2016
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.44 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 Converter
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var value = double.Parse(Console.ReadLine());
  14.             var type1 = Console.ReadLine();
  15.             var type2 = Console.ReadLine();
  16.  
  17.             double tmpValueBGN;
  18.             double result;
  19.  
  20.             if (type1 == "USD")
  21.             {
  22.                 tmpValueBGN = value * 1.79549;
  23.             }
  24.             else if (type1 == "GBP")
  25.             {
  26.                 tmpValueBGN = value * 2.53405;
  27.             }
  28.             else if (type1 == "EUR")
  29.             {
  30.                 tmpValueBGN = value * 1.95583;
  31.             }
  32.             else
  33.             {
  34.                 tmpValueBGN = value;
  35.             }
  36.  
  37.             // ---------------------------------------------
  38.  
  39.             if (type2 == "USD")
  40.             {
  41.                 result = tmpValueBGN / 1.79549;
  42.              
  43.             }
  44.             else if (type2 == "GBP")
  45.             {
  46.                 result = tmpValueBGN / 2.53405;
  47.             }
  48.             else if (type2 == "EUR")
  49.             {
  50.                 result = tmpValueBGN / 1.95583;
  51.             }
  52.             else
  53.             {
  54.                 result = tmpValueBGN;
  55.             }
  56.             Console.WriteLine(Math.Round(result, 2) + " "+type2);
  57.         }
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment