private bool ValidateInputs(List <StudentInformation> studentList, string id, string name, string mobile, int age, double gpa) { string studentID = id; string studentName = name; string studentMobile = mobile; int studentAge = age; double studentGPA = gpa; if (studentID.Length != 4) { ShowErrorMessage("ID should be of 4 characters!"); return(false); } if (studentName.Length == 0) { ShowErrorMessage("Name can not be empty!"); return(false); } if (studentMobile.Length != 11) { ShowErrorMessage("Mobile number should be of 11 characters!"); return(false); } if (CustomLibrary.HasDuplicateID(list: studentList, studentID)) { ShowErrorMessage("ID exists already!"); return(false); } if (CustomLibrary.HasDuplicateMobile(list: studentList, studentMobile)) { ShowErrorMessage("Mobile exists already!"); return(false); } if (studentAge == 0) { ShowErrorMessage("Age can not be 0!"); return(false); } if (studentGPA <= 0 || studentGPA > 4) { ShowErrorMessage("GPA should be between 0 and 4!"); return(false); } return(true); }
public static string DisplayMaxMinAvgTotal(List <StudentInformation> studentList) { string output = "\n\nDetails (Max, Min, Avg, Total):"; if (studentList.Count > 0) { output = "\nStudent : " + CustomLibrary.FindMaxInList(studentList).name + " - Max GPA: " + CustomLibrary.FindMaxInList(studentList).gpa + "\nStudent : " + CustomLibrary.FindMinInList(studentList).name + " - Min GPS: " + CustomLibrary.FindMinInList(studentList).gpa + "\nAverage : " + CustomLibrary.FindAvgOfList(studentList) + " - Total : " + CustomLibrary.FindTotalOfList(studentList) + "\n"; } return(output); }