C# Program to Generate Marksheet of Student - GeeksforGeeks

16 Oct, 2021
Given the marks of the students, now we generate a mark sheet of students by calculating three subject marks of students by entering student names and roll numbers.
Example:
Input:
Enter Student Roll-Number: 1
Enter Student Name: manoj
Enter Subject-1 Marks :90
Enter Subject-2 Marks :78
Enter Subject-3 Marks :96

Output:
Total Marks: 264
Percentage: 88
Grade is A
Approach
Declare the variables(i.e., marks1, marks2, and marks3) that will holds the marks of three subjects, i.e., Subject-1, Subject-2, and Subject-3.
Read the student data from the user.
Calculate total marks of the three subjects.
total = marks1 + marks2 + marks3;
Find the percentage.
 percentage = total / 3.0f;
Display the final percentage of the student.
Calculate and display the grades of the student also according to their percentage.
Example:
C#
// C# program to create marksheet for students.using System;using System.Collections.Generic;using System.Linq;using System.Text;   class GFG{      static void Main(string[] args){          // Declare variables for marks and total    int r, marks1, marks2, marks3, total;          // Declare percentage variable    float percentage;    string n;           // Enter student roll number    Console.WriteLine("Enter Student Roll Number :");    r = Convert.ToInt32(Console.ReadLine());          // Enter student name    Console.WriteLine("Enter Student Name :");    n = Console.ReadLine();          // Enter student subject 1 marks    Console.WriteLine("Enter Subject-1 Marks : ");    marks1 = Convert.ToInt32(Console.ReadLine());          // Enter student subject 2 marks    Console.WriteLine("Enter Subject-2 Marks : ");    marks2 = Convert.ToInt32(Console.ReadLine());          // Enter student subject 3 marks    Console.WriteLine("Enter Subject-3 Marks :");    marks3 = Convert.ToInt32(Console.ReadLine());          // Calculate total marks    total = marks1 + marks2 + marks3;          // Calculate percentage    percentage = total / 3.0f;          // Display the final result    Console.WriteLine("Final result of {0} is:", n);    Console.WriteLine("Total Marks : " + total);    Console.WriteLine("Percentage : " + percentage);          // Calculate grades    if (percentage <= 35)    {        Console.WriteLine("Grade is F");    }    else if (percentage >= 34 && percentage <= 39)    {        Console.WriteLine("Grade is D");    }    else if (percentage >= 40 && percentage <= 59)    {        Console.WriteLine("Grade is C");    }    else if (percentage >= 60 && percentage <= 69)    {        Console.WriteLine("Grade is B");    }    else if (percentage >= 70 && percentage <= 79)    {        Console.WriteLine("Grade is B+");    }    else if (percentage >= 80 && percentage <= 90)    {        Console.WriteLine("Grade is A");    }    else if (percentage >= 91)    {        Console.WriteLine("Grade is A+");    }}}
Output:
Enter Student Roll Number :
13
Enter Student Name :
Hitesh
Enter Subject-1 Marks :
56
Enter Subject-2 Marks :
78
Enter Subject-3 Marks :
87
Final result of Hitesh is:
Total Marks : 221
Percentage : 73.66666
Grade is B+
CSharp-programs
Picked
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Extension Method in C#
HashSet in C# with Examples
C# | Inheritance
Partial Classes in C#
C# | Generics - Introduction
Top 50 C# Interview Questions & Answers
Switch Statement in C#
Convert String to Character Array in C#
C# | How to insert an element in an Array?
Linked List Implementation in C#