jrliv
12/17/2016 - 7:36 PM

Example of how to use a switch statement.

Example of how to use a switch statement.

Console.WriteLine("Enter the grade letter: ");
char grade = Char.Parse(Console.ReadLine());

switch (grade)
{
  case 'A':
    Console.WriteLine("Excellent!");
    break;
  case 'C':
    Console.WriteLine("Well done");
    break;
  case 'D':
    Console.WriteLine("You passed");
    break;
  case 'F':
    Console.WriteLine("Better try again");
    break;
  default:
    Console.WriteLine("Invalid grade");
    break;
}
Console.WriteLine("Your grade is  {0}", grade);
Console.ReadLine();