Advertisement
tsvetelinapasheva

TsvetelinaPasheva/ConditionalStatementsExercise/04.MetricConverter

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