C# Program to Generate the Marksheet of the Student
Posted by Superadmin on August 15 2022 15:31:34

C# Program to Generate the Marksheet of the Student

 

 

This is a C# Program to generate the marksheet of the student.

Problem Description

This C# Program Generates the Marksheet of the Student.

Problem Solution

Here the student details are obtained from the user and the marksheet is generated based on the details.

Program/Source Code

Here is source code of the C# Program to Generate the Marksheet of the Student. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.

/*
 * C# Program to Generate the Marksheet of the Student
 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace Marksheet1
{
    class Program
    {
        static void Main(string[] args)
        {
            int r, m1, m2, m3, t;
            float p;
            string n;
            Console.WriteLine("Enter Roll Number :");
            r = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Enter Student Name :");
            n = Console.ReadLine();
            Console.WriteLine("Mark of Subject1 : ");
            m1 = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Mark of Subject2 : ");
            m2 = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Mark of Subject3 : ");
            m3 = Convert.ToInt32(Console.ReadLine());
            t = m1 + m2 + m3;
            p = t / 3.0f;
            Console.WriteLine("Total : " + t);
            Console.WriteLine("Percentage : " + p);
            if (p >= 35 && p < 50)
            {
                Console.WriteLine("Grade is C");
            }
            if (p >= 50 && p <= 60)
            {
                Console.WriteLine("Grade is B");
            }
            if (p > 60 && p <= 80)
            {
                Console.WriteLine("Grade is A");
            }
            if (p > 80 && p <= 100)
            {
                Console.WriteLine("Grade is A+");
            }
            Console.ReadLine();
        }
    }
}
Program Explanation

In this C# program, we are reading the Roll Number, Student Name, Mark of Subject1, Mark of Subject2, and Mark of Subject3 using ‘r’, ‘n’, ‘m1’, ‘m2’ and ‘m3’ variables respectively.

 

Compute the summation of total marks obtained by the user in three subjects. Divide the total marks in all the subjects by total number of subjects to compute the average. Print the student details obtained from the user and generate the marksheet based on the details.

Runtime Test Cases
 
Enter RollNumber : 
48
Enter Student Name :
sri
Mark of Subject1 :
90
Mark of Subject2 :
80
Mark of Subject3 :
70
Total : 240
Percentage : 80
Grade is A