C# Program Create a class student with a data members name and calculate marks and percentage.

C# Program Create a class student with a data member’s name and calculate marks and percentage.

Create a class student with a data members name and calculate marks and percentage.

Object:

C# Program Create a class student with a data member name, age, marks of English, marks of math, marks of science, total marks, obtained marks and percentage provide member functions CalculateTotalMarks and CalculatePercentage to calculate marks and percentage in main. C# Projects with Source Code

Code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Lab_3a
{
class students
{
public void data()
{
string name;
int age;
double eng, math, sci, obt_marks, total_marks=300, per;
Console.WriteLine(“Enter Student Name: “);
name=Console.ReadLine();
Console.WriteLine(“Enter Student Age: “);
age = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(“Enter Marks of English: “);
eng = Convert.ToDouble(Console.ReadLine());
Console.WriteLine(“Enter Marks of Math: “);
math = Convert.ToDouble(Console.ReadLine());
Console.WriteLine(“Enter Student Science: “);
sci = Convert.ToDouble(Console.ReadLine());
obt_marks = eng + math + sci;
per = (obt_marks / total_marks) * 100;
Console.WriteLine(“——————————————\n\n”);
Console.WriteLine(“Name of Student is: {0}”, name);
Console.WriteLine(“Student Age is : {0}”, age);
Console.WriteLine(“Obtained Marks : {0}”, obt_marks);
Console.WriteLine(“Percentage : {0}”, per);
}
}
class Program
{
static void Main()
{
students i = new students();
i.data();
Console.ReadKey();
}
}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Lab_3a
{
    class students
    {
        public void data()
        {
            string name;
            int age;
            double eng, math, sci, obt_marks, total_marks=300, per; 
            Console.WriteLine("Enter Student Name: ");
            name=Console.ReadLine();
            Console.WriteLine("Enter Student Age: ");
            age = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Enter Marks of English: ");
            eng = Convert.ToDouble(Console.ReadLine());
            Console.WriteLine("Enter Marks of Math: ");
            math = Convert.ToDouble(Console.ReadLine());
            Console.WriteLine("Enter Student Science: ");
            sci = Convert.ToDouble(Console.ReadLine());
            obt_marks = eng + math + sci;
            per = (obt_marks / total_marks) * 100;
            Console.WriteLine("------------------------------------------\n\n");
            Console.WriteLine("Name of Student is: {0}", name);
            Console.WriteLine("Student Age is : {0}", age);
            Console.WriteLine("Obtained Marks : {0}", obt_marks);
            Console.WriteLine("Percentage : {0}", per);
        }
    }
    class Program
    {
        static void Main()
        {
            students i = new students();
            i.data();
            Console.ReadKey();
        }
    }
}

Output:

C# Program Create a class student with a data members name and calculate marks and percentage.

Another Program: C# Program Calculating the Area of a Rectangle

Another Program: C# Program that Subtracts two user-defined numbers

7 thoughts on “C# Program Create a class student with a data members name and calculate marks and percentage.”

  1. Pingback: Develop a C# app that will determine the gross pay for each of three employees

  2. Pingback: Write a C# program that reads two arrays and checks whether they are equal.

  3. Pingback: C# program to count vowels in a string

  4. Pingback: Write a C# program to demonstrate the multiple inheritances

  5. Pingback: Implement bubble sort in C# the value of array given by the users

  6. Pingback: C# how to handle exceptions to illustrate try-catch action with Exceptions

  7. Pingback: Top 20 C# programs examples in 2021

Leave a Comment

Your email address will not be published. Required fields are marked *