Advertisement
Aliendreamer

currency converter with dictionary

Jun 15th, 2018
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.67 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.                    
  4. public class Program
  5. {
  6.    
  7.     public static void Main()
  8.     {
  9.             Dictionary<string, decimal> currency = new Dictionary<string,decimal>  
  10.             {
  11.               {"bgn",1M },
  12.               { "usd",1.79549M},
  13.               {"eur",1.95583M},
  14.               {"gbp",2.53405M}
  15.             };
  16.  
  17.             decimal price = decimal.Parse(Console.ReadLine());
  18.             string input = Console.ReadLine();
  19.             string output = Console.ReadLine();
  20.            
  21.             decimal outputCurrency=currency[output];
  22.             decimal valueInput = price * currency[input];
  23.             decimal valueOutput = (valueInput /outputCurrency );
  24.        
  25.         Console.WriteLine("{0:f2}",valueOutput);
  26.  
  27.     }
  28.    
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement