class Student:
    def __init__(self, student_id, name):
        self.id = student_id
        self.name = name


students = []
MAX_STUDENTS = 100

while True:

    print("\n===== Student Management System =====")
    print("1. Add Student")
    print("2. View Students")
    print("3. Search Student")
    print("4. Update Student")
    print("5. Delete Student")
    print("6. Exit")

    choice = int(input("Please choose an option: "))

    if choice == 1:

        if len(students) >= MAX_STUDENTS:
            print("Storage Full!")
            continue

        new_id = int(input("Enter Student ID: "))

        exists = False

        for student in students:
            if student.id == new_id:
                exists = True
                break

        if exists:
            print("Student ID Already Exists!")
            continue

        name = input("Enter Student Name: ")

        students.append(Student(new_id, name))

        print("Student Added Successfully!")

    elif choice == 2:

        if len(students) == 0:
            print("No Student Records Found.")
        else:

            print("\nID\tName")

            for student in students:
                print(student.id, "\t", student.name)

    elif choice == 3:

        search_id = int(input("Enter Student ID to Search: "))

        found = False

        for student in students:

            if student.id == search_id:

                print("ID:", student.id)
                print("Name:", student.name)

                found = True
                break

        if not found:
            print("Student Not Found.")

    elif choice == 4:

        update_id = int(input("Enter Student ID to Update: "))

        found = False

        for student in students:

            if student.id == update_id:

                student.name = input("Enter New Name: ")

                print("Record Updated Successfully!")

                found = True
                break

        if not found:
            print("Student Not Found.")

    elif choice == 5:

        delete_id = int(input("Enter Student ID to Delete: "))

        found = False

        for student in students:

            if student.id == delete_id:

                confirm = input("Are you sure? (Y/N): ")

                if confirm.lower() == "y":
                    students.remove(student)
                    print("Student Deleted Successfully!")
                else:
                    print("Delete Cancelled.")

                found = True
                break

        if not found:
            print("Student Not Found.")

    elif choice == 6:

        print("Exiting Program...")
        break

    else:
        print("Invalid Choice!")