Advertisement
kzborisov

metricConverter

Sep 16th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 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 Metric_Converter
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. double distance = double.Parse(Console.ReadLine());
  14. var metricInput = Console.ReadLine();
  15. var metricOutput = Console.ReadLine();
  16.  
  17. var metrics = new Dictionary<string, double>()
  18. {
  19. {"m", 1},
  20. {"mm", 1000},
  21. {"cm", 100},
  22. {"mi", 0.000621371192},
  23. {"in", 39.3700787},
  24. {"km", 0.001},
  25. {"ft", 3.2808399},
  26. {"yd", 1.0936133},
  27. };
  28.  
  29. var result = distance * (metrics[metricOutput] / metrics[metricInput]);
  30.  
  31. Console.WriteLine($"{result:F8}");
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement