Advertisement
veronikaaa86

Metric Converter

Jan 22nd, 2018
421
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.78 KB | None | 0 0
  1. using System;
  2.  
  3. namespace MetricConvertor
  4. {
  5.     public class Program
  6.     {
  7.         public static void Main(string[] args)
  8.         {
  9.             double value = double.Parse(Console.ReadLine());
  10.             string input = Console.ReadLine();
  11.             string output = Console.ReadLine();
  12.  
  13.             if (input == "mm")
  14.             {
  15.                 value /= 1000.0;
  16.             }
  17.             else if (input == "cm")
  18.             {
  19.                 value /= 100.0;
  20.             }
  21.             else if (input == "mi")
  22.             {
  23.                 value /= 0.000621371192;
  24.             }
  25.             else if (input == "in")
  26.             {
  27.                 value /= 39.3700787;
  28.             }
  29.             else if (input == "km")
  30.             {
  31.                 value /= 0.001;
  32.             }
  33.             else if (input == "ft")
  34.             {
  35.                 value /= 3.2808399;
  36.             }
  37.             else if (input == "yd")
  38.             {
  39.                 value /= 1.0936133;
  40.             }
  41.  
  42.             if (output == "mm")
  43.             {
  44.                 value *= 1000.0;
  45.             }
  46.             else if (output == "cm")
  47.             {
  48.                 value *= 100.0;
  49.             }
  50.             else if (output == "mi")
  51.             {
  52.                 value *= 0.000621371192;
  53.             }
  54.             else if (output == "in")
  55.             {
  56.                 value *= 39.3700787;
  57.             }
  58.             else if (output == "km")
  59.             {
  60.                 value *= 0.001;
  61.             }
  62.             else if (output == "ft")
  63.             {
  64.                 value *= 3.2808399;
  65.             }
  66.             else if (output == "yd")
  67.             {
  68.                 value *= 1.0936133;
  69.             }
  70.  
  71.             Console.WriteLine($"{value} {output:f8}");
  72.         }
  73.     }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement