COS 102 : Java Programming-II, Lab: Array of Objects
--------------------
Question#1:
Write the Java code for classes Student and Section Class Section:
AddStudent(student:stu): It will add the student details in the Array of objects(arrayStu) , returns true if successfully added otherwise it will return false.
SearchStudent(stuid:id): It will search for the detail of the student using the ID and return the index of the array. If not found, it returns -1.
calculateTotalAges(): calculate and returns the sum of ages of all students.
calculateAvgAge(): calculates and returns the average student age of the section.
printStuData( stuid:int): Prints the information about the student whose student id is stuid otherwise it displays “Student not Found”.
deleteStu(( stuid:int): This method will delete student with given id stuid and returns true otherwise returns false if student is not found
findMaxAge(): return the maximum age of the student in the section. findMinAge(): return the minimum age of the student in the section.
Question#2
Create a test class and creates an object of the Section class with size 10.
Create 5 students objects and add them in section.
Delete any one of the students, display maximum and minimum ages of the students in the section.
need an explanation for this answer? contact us directly to get an explanation for this answer