namespace ClassworkAdvancedClasses3._12._17
public static void Main(string[] args)
Console.WriteLine("how many students in class?");
int num = int.Parse(Console.ReadLine());
Student[] students = new Student[num];
Random rnd = new Random();
int id, day, month, year, numGrades = 3, top = 0;
for (int i = 0; i < num; i++)
id = rnd.Next(1000, 10000);
Console.WriteLine("insert name");
name = Console.ReadLine();
year = rnd.Next(2000, 2002);
d1 = new Date(day, month, year);
students[i] = new Student(id, name, d1, numGrades);
students[i].ReadGrades();
if (students[i].GetAverage() >= top)
top = students[i].GetAverage();
for (int h = 0; h < num; h++)
if (students[h].GetAverage()==top)
Console.WriteLine(students[h].ToString());
public Date(int day, int month, int year)
public Date(Date birthday)
this.month = birthday.month;
this.year = birthday.year;
public bool IsIntresting()
if (this.day == this.month)
if (this.day < 10 && this.day == this.year % 10)
if (this.day == this.year % 100)
int[] DaysInMonth = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
for (int i = 0; i < this.month - 1; i++)
if (DaysInYear() == 366 && month > 2)
public override string ToString()
string st = (this.day + " / " + this.month + " / " + this.year);
public Student(int id, String name, Date birthday, int numGrades)
this.birthday = new Date(birthday);
this.numGrades = numGrades;
this.grades = new int[numGrades];
public Date GetBirthday()
public void SetGrade(int place, int grade)
this.grades[place] = grade;
public void check(int grade)
while (grade>100 || grade<0)
Console.WriteLine("Unacceptable Grade, please change to a grade between 0 and 100 (including 0 and 100)");
grade = int.Parse(Console.ReadLine());
for (int i = 0; i < numGrades; i++)
Console.WriteLine("insert grade #"+i);
grade = int.Parse(Console.ReadLine());
for (int i = 0; i < numGrades; i++)
override public string ToString()
return "id: " + this.id + " name: " + this.name + " birthday: " + this.birthday +" average: "+GetAverage();