Advertisement
desislava_topuzakova

Untitled

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