C# Program to Read a Grade and Display the Equivalent Description

This is a C# Program to read a grade & display the equivalent description.

Problem Description

This C# Program Reads a Grade & Display the Equivalent Description.

Problem Solution

Here If grade is S, it prints super, if grade is A, it prints very good, if grade is B, it prints fair, if grade is Y, it prints absent, if grade is F, it prints fail.

Program/Source Code

Here is source code of the C# Program to Read a Grade & Display the Equivalent Description. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.

/*
 * C# Program to Read a Grade & Display the Equivalent Description
 */
using System;
using System.IO;
class program
{
    public static void Main()
    {
        char grade;
        Console.WriteLine("Enter the Grade in UpperCase \n");
        grade = Convert.ToChar(Console.ReadLine());
        switch (grade)
        {
        case 'S':
            Console.WriteLine(" SUPER");
            break;
        case 'A':
            Console.WriteLine(" VERY GOOD");
            break;
        case 'B':
            Console.WriteLine(" FAIR");
            break;
        case 'Y':
            Console.WriteLine(" ABSENT");
            break;
        case 'F':
            Console.WriteLine(" FAIL");
            break;
        default:
            Console.WriteLine("ERROR IN GRADE \n");
            break;
            Console.ReadLine();
        }
    }
}
Program Explanation

In this C# program, we are reading the grade using ‘grade’ variable. The toupper() function is used to convert the lower case letter of ‘grade’ variable value to upper case. Switch case statement is used to display equivalent grade description, if the grade variable value doesn’t match any value in case statement then execute the default statement. Print the equivalent description of the grade.

advertisement
advertisement
Runtime Test Cases
 
Enter the Grade in UpperCase
A
 VERY GOOD

Sanfoundry Global Education & Learning Series – 1000 C# Programs.

If you wish to look at all C# Programming examples, go to 1000 C# Programs.

If you find any mistake above, kindly email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.