Users Online

· Guests Online: 55

· Members Online: 0

· Total Members: 188
· Newest Member: meenachowdary055

Forum Threads

Newest Threads
No Threads created
Hottest Threads
No Threads created

Latest Articles

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

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.

 
Runtime Test Cases
 
Enter the Grade in UpperCase
A
 VERY GOOD

 

Comments

No Comments have been Posted.

Post Comment

Please Login to Post a Comment.

Ratings

Rating is available to Members only.

Please login or register to vote.

No Ratings have been Posted.
Render time: 0.80 seconds
10,856,086 unique visits