Boris-Stavrev92

Untitled

Jun 2nd, 2017
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 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 ConsoleApplication2
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. //Program2.task4();
  14. Program2.task5();
  15.  
  16.  
  17. }
  18. }
  19.  
  20. class Program2
  21. {
  22. public static void task4()
  23. {
  24.  
  25. var a = Console.ReadLine();
  26. var b = "";
  27. double val = double.Parse(Console.ReadLine());
  28.  
  29. double constant;
  30. switch (a)
  31. {
  32. case "miles":
  33. constant = 1.6;
  34. b = "kilometers";
  35. break;
  36.  
  37. case "inches":
  38. constant = 2.54;
  39. b = "centimeters";
  40. break;
  41.  
  42. case "feet":
  43. constant = 30;
  44. b = "centimeters";
  45. break;
  46.  
  47. case "yards":
  48. constant = 0.91;
  49. b = "meters";
  50. break;
  51.  
  52. case "gallons":
  53. constant = 3.8;
  54. b = "liters";
  55. break;
  56.  
  57. default:
  58. constant = 1;
  59. b = "";
  60. break;
  61.  
  62.  
  63. }
  64.  
  65.  
  66.  
  67. Console.Write(val);
  68. Console.Write(" ");
  69. Console.Write(a);
  70. Console.Write(" = ");
  71. Console.Write(Math.Round(val * constant, 2));
  72. Console.Write(" ");
  73. Console.WriteLine(b);
  74.  
  75.  
  76. }
  77.  
  78. public static void task5()
  79. {
  80. var a = Console.ReadLine();
  81. long f1 = 0;
  82. double f2 = 0;
  83. if(!long.TryParse(a, out f1))
  84. {
  85. Console.WriteLine("Rainy");
  86. }
  87. else
  88. {
  89. long.TryParse(a, out f1);
  90. if (f1 >= sbyte.MinValue && f1 <= sbyte.MaxValue) Console.WriteLine("Sunny");
  91. else if (f1 >= int.MinValue && f1 <= int.MaxValue) Console.WriteLine("Cloudy");
  92. else if (f1 >= long.MinValue && f1 <= long.MaxValue) Console.WriteLine("Windy");
  93. else Console.WriteLine("nope");
  94. //else if (f1 >= double.MinValue || f1 <= double.MinValue) Console.WriteLine("Rainy");
  95.  
  96. }
  97.  
  98.  
  99. }
  100.  
  101. }
  102.  
  103.  
  104.  
  105. }
Advertisement
Add Comment
Please, Sign In to add comment