Guest User

Untitled

a guest
Oct 12th, 2016
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 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. var lenght = double.Parse(Console.ReadLine());
  14. var inputType = Console.ReadLine();
  15. var outputType = Console.ReadLine();
  16.  
  17. var lenghtInMeters = 0.0;
  18.  
  19. if(inputType == "m")
  20. {
  21. lenghtInMeters = lenght / 1;
  22. }
  23. else if (inputType == "mm")
  24. {
  25. lenghtInMeters = lenght / 1000;
  26. }
  27. else if (inputType == "cm")
  28. {
  29. lenghtInMeters = lenght / 100;
  30. }
  31. else if (inputType == "mi")
  32. {
  33. lenghtInMeters = lenght / 0.000621371192;
  34. }
  35. else if (inputType == "in")
  36. {
  37. lenghtInMeters = lenght / 39.3700787;
  38. }
  39. else if (inputType == "km")
  40. {
  41. lenghtInMeters = lenght / 0.001;
  42. }
  43. else if (inputType == "ft")
  44. {
  45. lenghtInMeters = lenght / 3.2808399;
  46. }
  47. else
  48. {
  49. lenghtInMeters = lenght / 1.0936133;
  50. }
  51.  
  52. var outputLenght = 0.0;
  53.  
  54.  
  55. if (outputType == "m")
  56. {
  57. outputLenght = lenghtInMeters * 1;
  58. }
  59. else if (outputType == "mm")
  60. {
  61. outputLenght = lenghtInMeters * 1000;
  62. }
  63. else if (outputType == "cm")
  64. {
  65. outputLenght = lenghtInMeters * 100;
  66. }
  67. else if (outputType == "mi")
  68. {
  69. outputLenght = lenghtInMeters * 0.000621371192;
  70. }
  71. else if (outputType == "in")
  72. {
  73. outputLenght = lenghtInMeters * 39.3700787;
  74. }
  75. else if (outputType == "km")
  76. {
  77. outputLenght = lenghtInMeters * 0.001;
  78. }
  79. else if (outputType == "ft")
  80. {
  81. outputLenght = lenghtInMeters * 3.2808399;
  82. }
  83. else
  84. {
  85. outputLenght = lenghtInMeters * 1.0936133;
  86. }
  87.  
  88. Console.WriteLine("{0} {1}", outputLenght, outputType);
  89. }
  90. }
  91. }
Advertisement
Add Comment
Please, Sign In to add comment