Advertisement
knikolov98

Untitled

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