w3resource
C# Sharp Programming Exercises

C# Sharp Exercises: Accept a grade and display equivalent description


C# Sharp Conditional Statement: Exercise-19 with Solution

Write a program in C# Sharp to accept a grade and display the equivalent description :

Grade Description
E Excellent
V Very Good
G Good
A Average
F Fail

Sample Solution:-

C# Sharp Code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
public   class exercise19
   {
       static void Main(string[] args)
    {
    string notes;
    char grd;
          Console.Write("\n\n");
           Console.Write("Accept a grade and display equivalent description:\n");
           Console.Write("---------------------------------------------------");
           Console.Write("\n\n");

 
    Console.Write("Input the grade :");
    grd = Convert.ToChar(Console.ReadLine().ToUpper());

    switch(grd)
    {
    case 'E':
        notes= " Excellent";
        break;
    case 'V':
       notes= " Very Good";
        break;
    case 'G':
        notes= " Good ";
        break;
    case 'A':
        notes= " Average";
        break;
    case 'F':
        notes= " Fails";
        break;
    default :
        notes= "Invalid Grade Found.";
        break;
    }
    Console.Write("You have chosen  : {0}\n", notes);
} 
}

Sample Output:

Accept a grade and display equivalent description:                                                            
---------------------------------------------------                                                           
Input the grade :V                                                                                            
You have chosen  :  Very Good 

Flowchart:

Flowchart: Accept a grade and display equivalent description

C# Sharp Code Editor:

Contribute your code and comments through Disqus.

Previous: Write a program in C# Sharp to calculate and print the Electricity bill of a given customer.
Next: Write a program in C# Sharp to read any day number in integer and display day name in the word.

What is the difficulty level of this exercise?



New Content: Composer: Dependency manager for PHP, R Programming