Advertisement
Guest User

Untitled

a guest
Feb 21st, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.77 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. class Program
  5. {
  6.     static void Main()
  7.     {
  8.         double numberToConvert = double.Parse(Console.ReadLine());
  9.  
  10.         string firstUnit = Console.ReadLine();
  11.         string secondUnit = Console.ReadLine();
  12.  
  13.         var units = new Dictionary<string, double>()
  14.                               {
  15.             { "m", 1d },
  16.             { "mm", 1000d },
  17.             { "cm", 100d },
  18.             { "mi", 0.000621371192d },
  19.             { "in", 39.3700787d },
  20.             { "km", 0.001d },
  21.             { "ft", 3.2808399d },
  22.             { "yd", 1.0936133d}
  23.                                 };
  24.         double result = numberToConvert / units[firstUnit] * units[secondUnit];
  25.         Console.WriteLine(Math.Round(result, 8));
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement