Write a program with switch statement that accepts an input grade in percentile and grade equivalent table
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleAppCSharp
{
class Program
{
static void Main(string[] args)
{
Console.Write("Enter the grade in percentile form [0-100]: ");
int grade = int.Parse(Console.ReadLine());
switch (grade)
{
case int n when (n >= 98 && n <= 100):
Console.WriteLine("1.00");
break;
case int n when (n >= 95 && n <= 97):
Console.WriteLine("1.25");
break;
case int n when (n >= 92 && n <= 94):
Console.WriteLine("1.50");
break;
case int n when (n >= 89 && n <= 91):
Console.WriteLine("1.75");
break;
case int n when (n >= 85 && n <= 88):
Console.WriteLine("2.00");
break;
case int n when (n >= 82 && n <= 84):
Console.WriteLine("2.25");
break;
case int n when (n >= 80 && n <= 81):
Console.WriteLine("2.50");
break;
case int n when (n >= 77 && n <= 79):
Console.WriteLine("2.75");
break;
case int n when (n >= 75 && n <= 76):
Console.WriteLine("3.00");
break;
case int n when (n >= 60 && n <= 74):
Console.WriteLine("5.00");
break;
default:
Console.WriteLine("Out of range");
break;
}
Console.ReadLine();
}
}
}
Comments
Thank you very much for answering my question
Leave a comment