Advertisement
Sim0o0na

Untitled

Jan 19th, 2017
362
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.55 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 ConsoleApplication32
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             double value = double.Parse(Console.ReadLine());
  14.             string firstMetric = Console.ReadLine().ToLower();
  15.             string secondMetric = Console.ReadLine().ToLower();
  16.             double meter = 1.0;
  17.             double millimeters = 1000;
  18.             double centimeters = 100;
  19.             double miles = 0.000621371192;
  20.             double inches = 39.3700787;
  21.             double kilometers = 0.001;
  22.             double feet = 3.2808399;
  23.             double yards = 1.0936133;
  24.             double result = 0.0;
  25.             if (firstMetric == "m")
  26.             {
  27.                 if (secondMetric == "mm")
  28.                 {
  29.                     result = value * (millimeters / meter);
  30.                 }
  31.                 else if (secondMetric == "cm")
  32.                 {
  33.                     result = value * (centimeters / meter);
  34.                 }
  35.  
  36.                 else if (secondMetric == "mi")
  37.                 {
  38.                     result = value * (miles / meter);
  39.                 }
  40.                 else if (secondMetric == "in")
  41.                 {
  42.                     result = value * (inches / meter);
  43.                 }
  44.                 else if (secondMetric == "km")
  45.                 {
  46.                     result = value * (kilometers / meter);
  47.                 }
  48.                 else if (secondMetric == "ft")
  49.                 {
  50.                     result = value * (feet / meter);
  51.                 }
  52.                 else if (secondMetric == "yd")
  53.                 {
  54.                     result = value * (yards / meter);
  55.                 }
  56.             }
  57.             Console.WriteLine(result + " " + secondMetric);
  58.  
  59.             }
  60.  
  61.         }
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement