willsmythe37
10/2/2018 - 1:22 PM

C# Switch Example

C# Switch Example

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Switch_Example
{
    class Program
    {
        static void Main(string[] args)
        {
            string inputvalue;

            Console.WriteLine("Enter the mark you receieved");
            inputvalue = Console.ReadLine().ToUpper();

            char GradeRange = char.Parse(inputvalue);

            switch (GradeRange)
            {
                case 'A':
                    Console.WriteLine("For A, you need a mark of 70 - 100");
                    Console.ReadKey();
                    break;
                case 'B':
                    Console.WriteLine("For B, you need a mark of 60 - 69");
                    Console.ReadKey();
                    break;
                case 'C':
                    Console.WriteLine("For A, you need a mark of 50 - 59");
                    Console.ReadKey();
                    break;
                case 'D':
                    Console.WriteLine("For A, you need a mark of 40 - 49");
                    Console.ReadKey();
                    break;
                case 'F':
                    Console.WriteLine("For A, you need a mark of 0 - 39");
                    Console.ReadKey();
                    break;
                default:
                    Console.WriteLine("Invalid selection");
                    break;
            }
        }
    }
}