Anda di halaman 1dari 2

using using using using

System; System.Collections; System.Linq; System.Text;

namespace Shobha { class Student { static int Count; int StudId; int StuMarks; string StuName; static Student() { Count = 0; } public Student(string _Name, int _marks) { StuMarks = _marks; StuName = _Name; StudId = ++Count; } public void dispStudent() { Console.WriteLine(StuName + " " + StudId + " " + StuMarks); } public int getMarks() { return StuMarks; } public string getStuName() { return StuName; } } class StudentRecord { public static void Main(string[] args) { Stack st = new Stack(); st.Push(new Student("Ram", 88)); st.Push(new Student("Shyam", 89)); st.Push(new Student("Mercy", 87)); Student s; string name = null; int maxmarks = 0; while (st.Count > 0) { s = (Student)st.Pop(); if (s.getMarks() > maxmarks) { maxmarks = s.getMarks();

name = s.getStuName(); } } Console.WriteLine(name + " is the highest scorer");

} } }

Anda mungkin juga menyukai