Formula based program

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.
 
Formula based program

Note: If you are new to C# and Console Application. Try to code First C# Program

Note: Read articles on how to use Loops and Conditions.

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

Previous – Formula based program #9

Next – Formula based program #11

Click imagination hunt to read latest blogs.


Keep learning and sharing...

Comments

Popular posts from this blog

SSC CGL 2016 Tier-1 Marks / Result

DATA TYPES IN C#

Pattern printing program

IS STRING MUTABLE OR IMMUTABLE IN .NET?

Top Mutual Funds