# Metric Converter Fixed

Jun 28th, 2016
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. using System;
2. using System.Collections.Generic;
3. using System.Linq;
4. using System.Text;
6.
7. namespace MetricConverter
8. {
9. class MetricConverter
10. {
11. static void Main(string[] args)
12. {
13. decimal num = decimal.Parse(Console.ReadLine());
14. var firstMetric = Console.ReadLine().ToLower();
15. var secondMetric = Console.ReadLine().ToLower();
16.
17. decimal m = 1.0m;
18. decimal mm = 1000.0m;
19. decimal cm = 100.0m;
20. decimal mi = 0.000621371192m;
21. decimal inn = 39.3700787m;
22. decimal km = 0.001m;
23. decimal ft = 3.2808399m;
24. decimal yd = 1.0936133m;
25.
26. if (firstMetric == "m")
27. {
28. num = num / m;
29. }
30. else if (firstMetric == "mm")
31. {
32. num = num / mm;
33. }
34. else if (firstMetric == "cm")
35. {
36. num = num / cm;
37. }
38. else if (firstMetric == "mi")
39. {
40. num = num / mi;
41. }
42. else if (firstMetric == "in")
43. {
44. num = num / inn;
45. }
46. else if (firstMetric == "km")
47. {
48. num = num / km;
49. }
50. else if (firstMetric == "ft")
51. {
52. num = num / ft;
53. }
54. else if (firstMetric == "yd")
55. {
56. num = num / yd;
57. }
58.
59.
60. if (secondMetric == "m")
61. {
62. num = num * m;
63. }
64. else if (secondMetric == "mm")
65. {
66. num = num * mm;
67. }
68. else if (secondMetric == "cm")
69. {
70. num = num * cm;
71. }
72. else if (secondMetric == "mi")
73. {
74. num = num * mi;
75. }
76. else if (secondMetric == "in")
77. {
78. num = num * inn;
79. }
80. else if (secondMetric == "km")
81. {
82. num = num * km;
83. }
84. else if (secondMetric == "ft")
85. {
86. num = num * ft;
87. }
88. else if (secondMetric == "yd")
89. {
90. num = num * yd;
91. }
92. Console.WriteLine("{0} {1}", num, secondMetric);
93.
94. }
95. }
96. }