Pretorianbg

metric

Sep 23rd, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Metric_Converter
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. double num = double.Parse(Console.ReadLine());
  14. string from = Console.ReadLine();
  15. string to = Console.ReadLine();
  16.  
  17. if (from=="mm")
  18. {
  19. num = num / 1000;
  20. }
  21. else if (from=="m")
  22. {
  23. num = num / 1;
  24. }
  25. else if (from=="cm")
  26. {
  27. num = num / 100;
  28. }
  29. else if (from == "mi")
  30. {
  31. num = num / 0.000621371192;
  32. }
  33. else if (from == "in")
  34. {
  35. num = num / 39.3700787;
  36. }
  37. else if (from == "km")
  38. {
  39. num = num / 0.001;
  40. }
  41. else if (from == "ft")
  42. {
  43. num = num / 3.2808399;
  44. }
  45. else if (from == "yd")
  46. {
  47. num = num / 1.0936133;
  48. }
  49.  
  50. if (to=="mm")
  51. {
  52. num = num * 1000;
  53. }
  54. else if (to=="cm")
  55. {
  56. num = num * 100;
  57. }
  58. else if (to == "mi")
  59. {
  60. num = num * 0.000621371192;
  61. }
  62. else if (to == "in")
  63. {
  64. num = num * 39.3700787;
  65. }
  66. else if (to == "km")
  67. {
  68. num = num * 0.001;
  69. }
  70. else if (to == "ft")
  71. {
  72. num = num * 3.2808399;
  73. }
  74. else if (to == "yd")
  75. {
  76. num = num * 1.0936133;
  77. }
  78. Console.WriteLine($"{num:F8}");
  79. }
  80. }
  81. }
Add Comment
Please, Sign In to add comment