Created
July 14, 2022 06:18
-
-
Save bharathmuddada/99353f80c0e3eb37c08cdbe5d46af891 to your computer and use it in GitHub Desktop.
Example program for switch case
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SwitchCaseExample | |
{ | |
public static void Main(String[] args) | |
{ | |
Console.WriteLine("Enter any of the 3 seasons Summer , Winter, Rainy "); | |
string season = Console.ReadLine(); | |
switch (season) { | |
case "Summer": | |
Console.WriteLine($"{season} lasts from March to May"); | |
break; | |
case "Winter": | |
Console.WriteLine($"{season} lasts from December to January"); | |
break; | |
case "Rainy": | |
Console.WriteLine($"{season} lasts from June to September"); | |
break; | |
default: | |
Console.WriteLine("Enter a valid season"); | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment