Advertisement
ivanov_ivan

MetricConverter

Mar 15th, 2016
1,373
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.56 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 MetricConverter
  8. {
  9.     class MetricConverter
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var size = double.Parse(Console.ReadLine());
  14.             var sourceMetric = Console.ReadLine().ToLower();
  15.             var destMetric = Console.ReadLine().ToLower();
  16.  
  17.             if(sourceMetric == "mm")
  18.                 size = size / 1000;
  19.             if(sourceMetric == "cm")
  20.                 size = size / 100;
  21.             if(sourceMetric == "mi")
  22.                 size = size / 0.000621371192;
  23.             if(sourceMetric == "in")
  24.                 size = size / 39.3700787;
  25.             if(sourceMetric == "km")
  26.                 size = size / 0.001;
  27.             if(sourceMetric == "ft")
  28.                 size = size / 3.2808399;
  29.             if(sourceMetric == "yd")
  30.                 size = size / 1.0936133;
  31.  
  32.             if(destMetric == "mm")
  33.                 size = size * 1000;
  34.             if(destMetric == "cm")
  35.                 size = size * 100;
  36.             if(destMetric == "mi")
  37.                 size = size * 0.000621371192;
  38.             if(destMetric == "in")
  39.                 size = size * 39.3700787;
  40.             if(destMetric == "km")
  41.                 size = size * 0.001;
  42.             if(destMetric == "ft")
  43.                 size = size * 3.2808399;
  44.             if(destMetric == "yd")
  45.                 size = size * 1.0936133;
  46.  
  47.  
  48.             Console.WriteLine(size + " " + destMetric);
  49.  
  50.         }
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement