Formula #10 (Find student grade)
Enter percentage: 87
Hurrah! You got: A grade
The program for the formula is written
in C# programming language and will accept a number as a percentage. Based
on the formula it will find out the grade.
Let’s find out a simple and easy way
to code these formula.
Practical Implementation:
using System;
namespace patternProblem.Formula
{
class Formula10 //find student grade
{
static void Main(string[] args)
{
Console.Write("Enter percentage: ");
double percentage = Convert.ToDouble(Console.ReadLine());
if (percentage > 85)
{
Console.WriteLine("Hurrah! You got: A grade");
}
else
if (percentage < 85
&& percentage >= 75)
{
Console.WriteLine("Awesome! You got: B grade");
}
else
if (percentage < 75
&& percentage >= 50)
{
Console.WriteLine("Congratulation! You got: C
grade");
}
else
if (percentage < 50
&& percentage >= 33)
{
Console.WriteLine("Keep it up! You got: D grade");
}
else
{
Console.WriteLine("Sorry! You Failed.");
}
Console.ReadKey();
}
}
}
Output:
The input percentage
will decide what grade you achieve in your examination. The output is shown
below:
Enter percentage: 87
Hurrah! You got: A grade
Press any key to continue . . .
For any
query, comment us below.
Skip to
Main Table – Formula
based program
Keep learning and sharing...
No comments:
Post a Comment