Advertisement
mihael03

Metric_Converter

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