This Java program is a simple Student Management System that allows users to perform CRUD (Create, Read, Update, Delete) operations on student records. The system consists of three main classes:
StudentOperations.java- Handles the management of student records.Student.java- Represents a student entity with attributes such as name, PRN, batch, branch, and CGPA.Main.java- Provides a menu-driven interface to interact with the system.
This class manages a list of students using an ArrayList.
public StudentOperations(): Constructor that initializes theArrayListof students.public void addStudent(Student student): Adds a new student to the list.public void displayStudents(): Displays all students stored in the list by calling thedisplay()method of theStudentclass.
This class defines the structure of a student and contains getter and setter methods for each attribute.
private String name- Student's name.private long prn- Student's PRN (unique identification number).private String batch- Student's batch.private String branch- Student's branch of study.private float cgpa- Student's CGPA.
- Constructor:
public Student(String name, long prn, String batch, String branch, float cgpa)- Initializes a new student with provided details. - Setter Methods:
setName(String name),setPRN(long prn),setBatch(String batch),setBranch(String branch),setCGPA(float cgpa)- Updates respective attributes.
- Getter Methods:
getName(),getPRN(),getBatch(),getBranch(),getCGPA()- Retrieves respective attributes.
public void display(): Displays the student's details in a formatted manner.
This class contains the main method and provides a command-line interface for interacting with the student management system.
- Uses
Scannerfor user input. - Provides a menu-driven interface:
- Add a student (Takes input for all attributes and creates a
Studentobject). - Display all students.
- Exit the application.
- Add a student (Takes input for all attributes and creates a
- Uses a
switchcase inside awhile(true)loop to handle user choices.
- Compile all Java files using:
javac Main.java
- Run the program using:
java Main
- Follow the on-screen instructions to add and view student records.