public static SmartestStudent GetNoOf10sForAStudent(Student student) { var studentWith10s = new SmartestStudent(); int noOf10s = 0; for (int i = 0; i < student.subjects.Length; i++) for (int j = 0; j < student.subjects[i].marks.Length; j++) if (student.subjects[i].marks[j] == 10) noOf10s++; studentWith10s.studentName = student.Name; studentWith10s.noOf10s = noOf10s; return studentWith10s; }
public static SmartestStudent GetNoOf10sForAStudent(Student student) { var studentWith10s = new SmartestStudent(); int noOf10s = 0; for (int i = 0; i < student.subjects.Length; i++) { for (int j = 0; j < student.subjects[i].marks.Length; j++) { if (student.subjects[i].marks[j] == 10) { noOf10s++; } } } studentWith10s.studentName = student.Name; studentWith10s.noOf10s = noOf10s; return(studentWith10s); }
public static SmartestStudent GetStudentWithMost10s(Student[] students) { var noOf10sForFirstStudent = GetNoOf10sForAStudent(students[0]); var smartStudent = new SmartestStudent() { studentName = noOf10sForFirstStudent.studentName, noOf10s = noOf10sForFirstStudent.noOf10s }; for (int i = 1; i < students.Length; i++) { var result = GetNoOf10sForAStudent(students[i]); if (result.noOf10s > smartStudent.noOf10s) { smartStudent.noOf10s = result.noOf10s; smartStudent.studentName = result.studentName; } } return(smartStudent); }
public static SmartestStudent GetStudentWithMost10s(Student[] students) { var noOf10sForFirstStudent = GetNoOf10sForAStudent(students[0]); var smartStudent = new SmartestStudent() { studentName = noOf10sForFirstStudent.studentName, noOf10s = noOf10sForFirstStudent.noOf10s }; for (int i = 1; i < students.Length; i++) { var result = GetNoOf10sForAStudent(students[i]); if (result.noOf10s > smartStudent.noOf10s) { smartStudent.noOf10s = result.noOf10s; smartStudent.studentName = result.studentName; } } return smartStudent; }