Software & Finance





C# Simple Student Mark List Preparation





Here is C# source code for simple Mark List Preparation . You can add student name and marks for 5 subjects. Then you can view the student mark list.

 

This Program is a simple version and will not persist any data and you can not modify any data. To get the advanced version which does menu oriented persistant data, view the following links:

 

See Also:

 

Source Code


using System;

using System.Collections.Generic;

using System.Text;

using System.Runtime.InteropServices;

 

 

namespace CSMarkList

{

    class CStudent

    {

        public string name;

        public int[] marks = new int[5];

        public int total;

    }

 

    class CStudents

    {

        public List<CStudent> m_studList = new List<CStudent>();

 

        public int m_nMaxStudents;

       

        public int AddRecord(string name, int[] marks)

        {

            CStudent stud = new CStudent();

            stud.name = name;

            stud.marks = marks;

            stud.total = 0;

            for (int i = 0; i < 5; i++)

                stud.total += stud.marks[i];

            m_studList.Add(stud);

            m_nMaxStudents = m_studList.Count;

            return 1;

        }

    }

 

class Program

{

 

static public CStudents theStudents = new CStudents();

 

       

static public void ViewRecords()

{

 

            Console.WriteLine("_______________________________________________________________");

 

Console.WriteLine("SNo Student Name       Sub1   Sub2   Sub3   Sub4   Sub5   Total");

            Console.WriteLine("_______________________________________________________________");

 

for (int i = 0; i < theStudents.m_nMaxStudents; i++)

{

      Console.Write("{0, -5}", i + 1);

      Console.Write("{0, -19}", theStudents.m_studList[i].name);

      Console.Write("{0, -7}", theStudents.m_studList[i].marks[0]);

      Console.Write("{0, -7}", theStudents.m_studList[i].marks[1]);

      Console.Write("{0, -7}", theStudents.m_studList[i].marks[2]);

      Console.Write("{0, -7}", theStudents.m_studList[i].marks[3]);

      Console.Write("{0, -7}", theStudents.m_studList[i].marks[4]);

      Console.Write("{0, -7}", theStudents.m_studList[i].total);

      Console.WriteLine();

}

            Console.WriteLine("_______________________________________________________________");

}

 

static public void InputRecords()

{   

      Console.Write("Student Name: ");

      string name;

      int[] marks = new int[5];

      name = Console.ReadLine();

 

      for(int i = 1; i <= 5; i++)

      {

            Console.Write("Sub " + i.ToString() + " Mark: ");

            marks[i-1] = Convert.ToInt32(Console.ReadLine());

      }

      theStudents.AddRecord(name, marks);

}       

 

static void Main(string[] args)

{

 

      Console.WriteLine("Welcome to Student MarkList Application");

      Console.Write("Enter the number of students: ");

      int numStudents = -1;

      string s = Console.ReadLine();

      numStudents = Convert.ToInt32(s);

 

      for (int i = 1; i <= numStudents; i++)

      {

            Console.WriteLine("\nEnter " + i.ToString() + " Student Information\n");

            InputRecords();

      }

      ViewRecords();

      char ch = Console.ReadKey().KeyChar;

}

}

}

Output


Welcome to Student MarkList Application

Enter the number of Students: 3

 

 

Enter the 1 student information:

Student Name: AAA

Sub 1 Mark:40

Sub 2 Mark:50

Sub 3 Mark:60

Sub 4 Mark:70

Sub 5 Mark:80

 

 

Enter the 2 student information:

Student Name: BBB

Sub 1 Mark:80

Sub 2 Mark:80

Sub 3 Mark:70

Sub 4 Mark:670

Sub 5 Mark:90

 

 

Enter the 3 student information:

Student Name: CCC

Sub 1 Mark:100

Sub 2 Mark:90

Sub 3 Mark:99

Sub 4 Mark:88

Sub 5 Mark:89

_______________________________________________________________

SNo Student Name       Sub1   Sub2   Sub3   Sub4   Sub5   Total

_______________________________________________________________

  1 AAA                 40     50     60     70     80     300

  2 BBB                 80     80     70     670    90     990

  3 CCC                 100    90     99     88     89     466

_______________________________________________________________