Advertisement
mirozspace

MetricUnits

Apr 17th, 2020
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.85 KB | None | 0 0
  1. using System;
  2.  
  3. namespace MetricUnits
  4. {
  5.     class Program
  6.     {
  7.         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.             double result = 0.0;
  14.  
  15.             if(input == "mm")
  16.             {
  17.                 result = value / 1000;
  18.             }
  19.             else if (input == "cm")
  20.             {
  21.                 result = value / 100;
  22.             }else if (input == "m")
  23.             {
  24.                 result = value;
  25.             }
  26.  
  27.             if(output == "mm")
  28.             {
  29.                 result *= 1000;
  30.             }
  31.             else if(output == "cm")
  32.             {
  33.                 result *= 100;
  34.             }
  35.             Console.WriteLine("{0:F3}", result);
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement