Enter the Grade in UpperCase A VERY GOOD
Users Online
· Members Online: 0
· Total Members: 188
· Newest Member: meenachowdary055
Forum Threads
Latest Articles
Articles Hierarchy
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.
This C# Program Reads a Grade & Display the Equivalent Description.
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.
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(); } } }
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.