o_ignatov

more_exercises_05

Jun 2nd, 2017
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 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 _05_Weather_forecast
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. string input = Console.ReadLine();
  14. if (input.Contains('.'))
  15. {
  16. Console.WriteLine("Rainy");
  17. }
  18. else
  19. {
  20. bool trySmall = false;
  21. try
  22. {
  23. long num = long.Parse(input);
  24. trySmall = true;
  25. }
  26. catch
  27. {
  28. trySmall = false;
  29. }
  30. if (trySmall)
  31. {
  32. try
  33. {
  34. int num = int.Parse(input);
  35. trySmall = true;
  36. }
  37. catch
  38. {
  39. Console.WriteLine("Windy");
  40. trySmall = false;
  41. }
  42. }
  43. if (trySmall && !input.StartsWith("-") && int.Parse(input) > 127)
  44. {
  45. try
  46. {
  47. byte num = byte.Parse(input);
  48. Console.WriteLine("Sunny");
  49. trySmall = false;
  50. }
  51. catch
  52. {
  53. Console.WriteLine("Cloudy");
  54. }
  55.  
  56. }
  57. if (trySmall)
  58. {
  59. try
  60. {
  61. sbyte num = sbyte.Parse(input);
  62. Console.WriteLine("Sunny");
  63. }
  64. catch
  65. {
  66. Console.WriteLine("Cloudy");
  67. }
  68.  
  69. }
  70.  
  71. }//eof Else
  72. }
  73. }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment