Advertisement
MartinZarev

Untitled

Apr 30th, 2020
674
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.31 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Demo
  4. {
  5.     class Program
  6.     {
  7.         static void Main()
  8.         {
  9.             double number = double.Parse(Console.ReadLine());
  10.             string inputUnit = Console.ReadLine();
  11.             string outputUnit = Console.ReadLine();
  12.             double mm = 1000;
  13.             double cm = 100;
  14.             double m = 10;
  15.  
  16.             if (outputUnit == "mm")
  17.             {
  18.                 if (inputUnit == "cm")
  19.                 {
  20.                     number /= cm;
  21.                 }
  22.                 if (inputUnit == "m")
  23.                 {
  24.                     number /= mm;
  25.                 }
  26.             }
  27.             else if (outputUnit == "cm")
  28.             {
  29.                 if (inputUnit == "mm")
  30.                 {
  31.                     number *= m;
  32.                 }
  33.                 if (inputUnit == "m")
  34.                 {
  35.                     number /= m;
  36.                 }
  37.             }
  38.             else if (outputUnit == "m")
  39.             {
  40.                 if (inputUnit == "mm")
  41.                 {
  42.                     number *= mm;
  43.                 }
  44.                 if (inputUnit == "cm")
  45.                 {
  46.                     number *= cm;
  47.                 }
  48.             }
  49.             Console.WriteLine($"{number:f3}");
  50.  
  51.  
  52.  
  53.         }
  54.        
  55.  
  56.        
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement