grach

Currency Converter

Jul 7th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.16 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.  
  14.             var num = double.Parse(Console.ReadLine());
  15.             string a = " BGN";
  16.  
  17.             var inCurrency = Console.ReadLine();
  18.             var outCurrency = Console.ReadLine();
  19.  
  20.            
  21.  
  22.             if (inCurrency == "USD")
  23.             { num *= 1.79549; }
  24.             else if (inCurrency == "EUR")
  25.             { num *= 1.95583; }
  26.             else if (inCurrency == "GBP")
  27.             { num *= 2.53405; }
  28.  
  29.  
  30.             if (outCurrency == "USD")
  31.             { num /= 1.79549;
  32.               a =" USD"; }
  33.             else if (outCurrency == "EUR")
  34.             { num /= 1.95583;
  35.                 a = " EUR";
  36.             }
  37.             else if (outCurrency == "GBP")
  38.             { num /= 2.53405;
  39.                 a = " GBP";
  40.             }
  41.  
  42.  
  43.  
  44.             Console.Write(Math.Round (num, 2));
  45.             Console.WriteLine(a);
  46.  
  47.             // Console.WriteLine(Math.Round (num,2)+ "" + outCurrency);
  48.             // Console.WriteLine(Math.Round (num + " " + outCurrency);
  49.  
  50.         }
  51.     }
  52. }
  53. /*
  54. using System;
  55. using System.Collections.Generic;
  56. using System.Linq;
  57. using System.Text;
  58. using System.Threading.Tasks;
  59.  
  60. namespace Currency_Converter
  61. {
  62.     class Program
  63.     {
  64.         static void Main(string[] args)
  65.         {
  66.  
  67.             var num = double.Parse(Console.ReadLine());
  68.             var inCurrency = Console.ReadLine();
  69.             var outCurrency = Console.ReadLine();
  70.  
  71.             if (inCurrency == "USD")
  72.             { num *= 1.79549; }
  73.             else if (inCurrency == "EUR")
  74.             { num *= 1.95583; }
  75.             else if (inCurrency == "GBP")
  76.             { num *= 2.53405; }
  77.  
  78.  
  79.             if (outCurrency == "USD")
  80.             { num /= 1.79549; }
  81.             else if (outCurrency == "EUR")
  82.             { num /= 1.95583; }
  83.             else if (outCurrency == "GBP")
  84.             { num /= 2.53405; }
  85.  
  86.  
  87.  
  88.             Console.WriteLine(Math.Round(num, 2));
  89.  
  90.  
  91.         }
  92.     }
  93. }
  94. */
Advertisement
Add Comment
Please, Sign In to add comment