import java.util.Arrays;
import java.util.Scanner;

public class Student {
    private String name;
    private String id;
    private int age;
    private double grade;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public double getGrade() {
        return grade;
    }

    public void setGrade(double grade) {
        this.grade = grade;
    }
}

public class StudentManagement {
    private static Student[] students;
    private static int totalStudents;

    public StudentManagement() {
        students = new Student[10]; // Initialize with a default size
        totalStudents = 0;
    }

    public static void addStudent(String name, String id, int age, double grade) {
        Student student = new Student();
        student.setName(name);
        student.setId(id);
        student.setAge(age);
        student.setGrade(grade);

        if (totalStudents >= students.length) {
            // Resize the students array if necessary
            students = Arrays.copyOf(students, students.length * 2);
        }

        students[totalStudents] = student;
        totalStudents++;
    }

    public static void updateStudent(String id, String name, int age, double grade) {
        boolean found = false;
        for (int i = 0; i < totalStudents; i++) {
            if (students[i].getId().equals(id)) {
                students[i].setName(name);
                students[i].setAge(age);
                students[i].setGrade(grade);
                found = true;
                break;
            }
        }

        if (!found) {
            System.out.println(“Student with ID " + id + " not found.”);
        }
    }

    public static void getStudentDetails(String id) {
        boolean found = false;
        for (int i = 0; i < totalStudents; i++) {
            if (students[i].getId().equals(id)) {
                System.out.println(“Student Details:”);
                System.out.println("Name: " + students[i].getName());
                System.out.println("ID: " + students[i].getId());
                System.out.println("Age: " + students[i].getAge());
                System.out.println("Grade: " + students[i].getGrade());
                found = true;
                break;
            }
        }

        if (!found) {
            System.out.println(“Student with ID " + id + " not found.”);
        }
    }
}

public class AdministratorInterface {
    private static StudentManagement studentManagement;
    private static Scanner sc;

    public static void main(String[] args) {
        studentManagement = new StudentManagement();
        sc = new Scanner(System.in);

        boolean exit = false;
        while (!exit) {
            System.out.println(“Menu:”);
            System.out.println(“1. Add a new student”);
            System.out.println(“2. Update student information”);
            System.out.println(“3. View student details”);
            System.out.println(“4. Exit”);
            System.out.print("Select an option: ");

            int option = sc.nextInt();
            sc.nextLine(); // Consume newline character

            switch (option) {
                case 1:
                    addNewStudent();
                    break;
                case 2:
                    updateStudentInformation();
                    break;
                case 3:
                    viewStudentDetails();
                    break;
                case 4:
                    exit = true;
                    break;
                default:
                    System.out.println(“Invalid option. Please try again.”);
            }

            System.out.println();
        }

        sc.close();
    }

    public static void addNewStudent() {
        System.out.println(“Enter student name:”);
        String name = sc.nextLine();

        System.out.println(“Enter student ID:”);
        String id = sc.nextLine();

        System.out.println(“Enter student age:”);
        int age = sc.nextInt();

        System.out.println(“Enter student grade:”);
        double grade = sc.nextDouble();

        studentManagement.addStudent(name, id, age, grade);
        System.out.println(“New student added successfully.”);
    }

    public static void updateStudentInformation() {
        System.out.println(“Enter student ID:”);
        String id = sc.nextLine();

        System.out.println(“Enter new student name:”);
        String name = sc.nextLine();

        System.out.println(“Enter new student age:”);
        int age = sc.nextInt();

        System.out.println(“Enter new student grade:”);
        double grade = sc.nextDouble();

        studentManagement.updateStudent(id, name, age, grade);
    }

    public static void viewStudentDetails() {
        System.out.println(“Enter student ID:”);
        String id = sc.nextLine();

        studentManagement.getStudentDetails(id);
    }
}