package managestudent; import java.util.Scanner; class Student { int ID; String name; int age; public void inputInformation(int xID, String xName, int xAge) { ID = xID; name = xName; age = xAge; } public void outputInformation() { System.out.println(ID + " - " + name + " - " + age); } } class ManyStudents { int ID = 0, age = 0; String name = null; Scanner input = new Scanner(System.in); Student[] studentX = new Student[30]; int num; public void searchAge() { for (int i = 0; i < num; i++) { if (studentX[i].age <= 18) { studentX[i].outputInformation(); } } } public void inputMany() { System.out.println("Input the number of student: "); num = input.nextInt(); for (int i = 0; i < num; i++) { studentX[i] = new Student(); System.out.print(i + 1 + ". "); System.out.println("#Input :"); System.out.print("+ ID student :"); ID = input.nextInt(); System.out.print("+ Name of student: "); // clear cache input.nextLine(); name = input.nextLine(); System.out.print("+ Age of student: "); age = input.nextInt(); studentX[i].inputInformation(ID, name, age); } } public void outputMany() { System.out.println("----------------------------------------"); for (int i = 0; i < num; i++) { studentX[i].outputInformation(); } } } public class ManageStudent { public static void main(String[] args) { ManyStudents manySt = new ManyStudents(); manySt.inputMany(); manySt.outputMany(); System.out.println("----------------------------------------"); manySt.searchAge(); } }