You are on page 1of 5

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace ConsoleApplication5

class Student

private string name;

private int rollno;

private long fee;

public void setname(string name)

this.name = name;

public string getname()

return this.name;

public void setrollno(int rollno)

this.rollno = rollno;

public int getrollno()

return this.rollno;
}

public void setfee(long fee)

this.fee = fee;

public long getfee()

return this.fee;

namespace ConsoleApplication5

class Program

static void Main(string[] args)

int choice, ch;

string st_name;

int st_rollno;

long st_fee;

int st_count = 0;

Student[] students = new Student[4];

do
{

Console.Clear();

Console.Write("\tWelcome to Student detail\n");

Console.WriteLine("\n\t___________________________________________");

Console.WriteLine("\t\t\t*****MENU*****");

Console.WriteLine("\t___________________________________________");

Console.WriteLine("\n\t1.Add a Student To Record");

Console.WriteLine("\n\t2.Display All the Student Database");


Console.WriteLine("\n\n\tEnter Your Choice :. ");

choice = Convert.ToInt32(Console.ReadLine());

switch (choice)

case 1:

//adding a student record

Console.Clear();

Console.WriteLine("\n\tEnter Name of Student :. ");

st_name = Convert.ToString(Console.ReadLine());

Console.WriteLine("\tEnter Roll no :. ");

st_rollno = Convert.ToInt32(Console.ReadLine());

Console.WriteLine("\tEnter fee :. ");

st_fee = Convert.ToInt64(Console.ReadLine());

students[st_count] = new Student();

students[st_count].setname(st_name);

students[st_count].setrollno(st_rollno);

students[st_count].setfee(st_fee);

if (st_count < 3)
st_count++;

break;

case 2:

//for Display All the Student Database

Console.Clear();

int i = 1; //for serial number

Console.WriteLine("\n\t___________________________________________________________
___");

Console.WriteLine("\tSr No\tStudent Name\tROll no\fees");

Console.WriteLine("\t_____________________________________________________________
_");

foreach (Student stud in students)

if (stud != null)

Console.WriteLine("\n\t" + i + "\t" +
stud.getname() + "\t" + stud.getrollno() + "\t" + stud.getfee());

/*Console.WriteLine("\t" +stud.getname());

Console.WriteLine("\t" +stud.getrollno());

Console.WriteLine("\t" +stud.getfee());*/

i++;

Console.WriteLine("\t_____________________________________________________________
_");

break;
default:

Console.WriteLine("Wrong Choice");

break;

Console.WriteLine("\tDo you Want to CONTINUE?\n1.YES");

ch = Convert.ToInt32(Console.ReadLine());

} while (ch == 1);

You might also like