Advertisement
VPanev

Guess the Seasons task C#

Sep 15th, 2021
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.00 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp1
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string month = Console.ReadLine();
  10.             int date = int.Parse(Console.ReadLine());
  11.             string season = string.Empty;
  12.  
  13.  
  14.  
  15.             switch (month)
  16.             {
  17.                 case "January":
  18.                 case "February":
  19.                 case "March":
  20.                     if (date >= 1 && 19 >= date)
  21.                     {
  22.                         season = "Winter";
  23.                     }
  24.                     else if (date >= 20 && date <= 31)
  25.                     {
  26.                         season = "Spring";
  27.                     }
  28.                     break;
  29.  
  30.                 case "April":
  31.                 case "May":
  32.                 case "June":
  33.                     if (date >= 1 && 20 >= date)
  34.                     {
  35.                         season = "Spring";
  36.                     }
  37.                     else if (date >= 21 && date <= 30)
  38.                     {
  39.                         season = "Summer";
  40.                     }
  41.                     break;
  42.  
  43.                 case "July":
  44.                 case "August":
  45.                 case "September":
  46.                     if (date >= 1 && 21 >= date)
  47.                     {
  48.                         season = "Summer";
  49.                     }
  50.                     else if (date >= 22 && date <= 31)
  51.                     {
  52.                         season = "Autumn";
  53.                     }
  54.                     break;
  55.  
  56.                 case "October":
  57.                 case "November":
  58.                 case "December":
  59.                     if (date >= 1 && 20 >= date)
  60.                     {
  61.                         season = "Autumn";
  62.                     }
  63.                     else if (date >= 21 && date <= 31)
  64.                     {
  65.                         season = "Winter";
  66.                     }
  67.                     break;
  68.             }
  69.             Console.WriteLine(season);
  70.  
  71.  
  72.  
  73.         }
  74.     }
  75. }
  76.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement