0% found this document useful (0 votes)
65 views6 pages

Student Management System Project

The document outlines a Java program for a Student Management System that allows adding, viewing, updating, and deleting student records. It defines a Student class with attributes like ID, name, age, and grade, along with corresponding methods for accessing and modifying these attributes. The main class initiates the system and provides a menu-driven interface for user interaction.

Uploaded by

rickyburudi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views6 pages

Student Management System Project

The document outlines a Java program for a Student Management System that allows adding, viewing, updating, and deleting student records. It defines a Student class with attributes like ID, name, age, and grade, along with corresponding methods for accessing and modifying these attributes. The main class initiates the system and provides a menu-driven interface for user interaction.

Uploaded by

rickyburudi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Import java.util.

ArrayList;

Import java.util.Scanner;

Class Student {

Private int id;

Private String name;

Private int age;

Private String grade;

Public Student(int id, String name, int age, String grade) {

This.id = id;

This.name = name;

This.age = age;

This.grade = grade;

// Getters and Setters

Public int getId() {

Return id;

Public String getName() {

Return name;

Public int getAge() {

Return age;

}
Public String getGrade() {

Return grade;

Public void setName(String name) {

This.name = name;

Public void setAge(int age) {

This.age = age;

Public void setGrade(String grade) {

This.grade = grade;

@Override

Public String toString() {

Return “ID: “ + id + “, Name: “ + name + “, Age: “ + age + “, Grade:


“ + grade;

Class StudentManagementSystem {

Private ArrayList<Student> students;

Private Scanner scanner;

Public StudentManagementSystem() {

Students = new ArrayList<>();


Scanner = new Scanner(System.in);

Public void addStudent() {

System.out.print(“Enter ID: “);

Int id = scanner.nextInt();

Scanner.nextLine(); // Consume newline

System.out.print(“Enter Name: “);

String name = scanner.nextLine();

System.out.print(“Enter Age: “);

Int age = scanner.nextInt();

Scanner.nextLine(); // Consume newline

System.out.print(“Enter Grade: “);

String grade = scanner.nextLine();

Students.add(new Student(id, name, age, grade));

System.out.println(“Student added successfully.”);

Public void viewStudents() {

If (students.isEmpty()) {

System.out.println(“No students found.”);

} else {

For (Student student : students) {

System.out.println(student);

}
Public void updateStudent() {

System.out.print(“Enter ID of the student to update: “);

Int id = scanner.nextInt();

Scanner.nextLine(); // Consume newline

For (Student student : students) {

If (student.getId() == id) {

System.out.print(“Enter new Name: “);

Student.setName(scanner.nextLine());

System.out.print(“Enter new Age: “);

Student.setAge(scanner.nextInt());

Scanner.nextLine(); // Consume newline

System.out.print(“Enter new Grade: “);

Student.setGrade(scanner.nextLine());

System.out.println(“Student updated successfully.”);

Return;

System.out.println(“Student with ID “ + id + “ not found.”);

Public void deleteStudent() {

System.out.print(“Enter ID of the student to delete: “);

Int id = scanner.nextInt();

Scanner.nextLine(); // Consume newline

For (Student student : students) {

If (student.getId() == id) {
Students.remove(student);

System.out.println(“Student deleted successfully.”);

Return;

System.out.println(“Student with ID “ + id + “ not found.”);

Public void start() {

While (true) {

System.out.println(“\n--- Student Management System ---“);

System.out.println(“1. Add Student”);

System.out.println(“2. View Students”);

System.out.println(“3. Update Student”);

System.out.println(“4. Delete Student”);

System.out.println(“5. Exit”);

System.out.print(“Choose an option: “);

Int choice = scanner.nextInt();

Switch (choice) {

Case 1:

addStudent();

break;

case 2:

viewStudents();

break;

case 3:

updateStudent();
break;

case 4:

deleteStudent();

break;

case 5:

System.out.println(“Exiting...”);

Return;

Default:

System.out.println(“Invalid choice. Please try again.”);

Public class Main {

Public static void main(String[] args) {

StudentManagementSystem sms = new


StudentManagementSystem();

Sms.start();

You might also like