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
Pictorial Presentation:
Flowchart:
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?
Test your Programming skills with w3resource's quiz.
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework