Advertisement
Andonoff

Untitled

May 28th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.81 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace MetricConverter
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             double fromMetric = double.Parse(Console.ReadLine());
  11.             string from = Console.ReadLine();
  12.             string to = Console.ReadLine();
  13.             var currecies = new Dictionary<string, double>()
  14.             {
  15.                 {"m", 1.0 },
  16.                 {"mm", 1000.0 },
  17.                 {"cm", 100 },
  18.                 {"mi", 0.000621371192},
  19.                 {"in", 39.3700787},
  20.                 {"km", 0.001},
  21.                 {"ft", 3.2808399},
  22.                 {"yd", 1.0936133}
  23.             };
  24.             double result = fromMetric / currecies[from] * currecies[to];
  25.             Console.WriteLine($"{result:F8}");
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement