School Management System in Java

Our School Management System is designed to manage students, teachers, and courses within a school. It allows for adding new members to each category, displaying the list of members, and managing course assignments. This system uses core Java concepts, making it an excellent project for beginners looking to apply their knowledge in a real-world scenario.

System Design 

The system comprises three main components: Student, Teacher, and Course, each represented by a Java class with attributes reflecting their real-world counterparts. For instance, the Student class includes id, name, and grade attributes, while the Teacher and Course classes contain attributes suitable for their specific roles within the school system. 

Core Features 

Add New Members: The system supports adding new students, teachers, and courses via user input.

Display Lists: It can display comprehensive lists of students, teachers, and courses, providing a quick overview of the school's current roster. 

Interactive User Input: The system utilizes Java's Scanner class to prompt users to enter details for new students, teachers, and courses, making data entry interactive and straightforward.

Implementation

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Student {
    int id;
    String name;
    int grade;

    Student(int id, String name, int grade) {
        this.id = id;
        this.name = name;
        this.grade = grade;
    }

    @Override
    public String toString() {
        return "Student ID: " + id + ", Name: " + name + ", Grade: " + grade;
    }
}

class Teacher {
    int id;
    String name;

    Teacher(int id, String name) {
        this.id = id;
        this.name = name;
    }

    @Override
    public String toString() {
        return "Teacher ID: " + id + ", Name: " + name;
    }
}

class Course {
    int id;
    String name;

    Course(int id, String name) {
        this.id = id;
        this.name = name;
    }

    @Override
    public String toString() {
        return "Course ID: " + id + ", Name: " + name;
    }
}

public class SchoolManagementSystem {
    List<Student> students = new ArrayList<>();
    List<Teacher> teachers = new ArrayList<>();
    List<Course> courses = new ArrayList<>();

    Scanner scanner = new Scanner(System.in);

    public void addStudent() {
        System.out.println("Enter Student ID, Name, and Grade:");
        int id = scanner.nextInt();
        String name = scanner.next();
        int grade = scanner.nextInt();
        students.add(new Student(id, name, grade));
    }

    public void addTeacher() {
        System.out.println("Enter Teacher ID and Name:");
        int id = scanner.nextInt();
        String name = scanner.next();
        teachers.add(new Teacher(id, name));
    }

    public void addCourse() {
        System.out.println("Enter Course ID and Name:");
        int id = scanner.nextInt();
        String name = scanner.next();
        courses.add(new Course(id, name));
    }

    public void printStudents() {
        System.out.println("Students:");
        students.forEach(System.out::println);
    }

    public void printTeachers() {
        System.out.println("\nTeachers:");
        teachers.forEach(System.out::println);
    }

    public void printCourses() {
        System.out.println("\nCourses:");
        courses.forEach(System.out::println);
    }

    public static void main(String[] args) {
        SchoolManagementSystem system = new SchoolManagementSystem();

        // Taking input from the user
        system.addStudent(); // Add at least one student
        system.addTeacher(); // Add at least one teacher
        system.addCourse(); // Add at least one course

        // Printing the entities
        system.printStudents();
        system.printTeachers();
        system.printCourses();
    }
}

Implementation Highlights

Model Classes

Each entity in the school management system is modeled as a Java class (Student, Teacher, and Course). These classes are designed with simplicity in mind, containing attributes and constructors necessary for creating new instances.

Adding New Members

The system's capability to add new members is facilitated by methods like addStudent(), addTeacher(), and addCourse(), which read user inputs and store the new instances in respective ArrayLists.

Displaying Information

Methods such as printStudents(), printTeachers(), and printCourses() iterate over their respective ArrayLists, displaying each member's details using the toString() method overridden in each model class.

Instructions 

  1. Compile the Java program. 
  2. Run the compiled program. 
  3. The program will prompt you to enter details for a student, a teacher, and a course. Input the details as prompted. 
  4. For names with spaces, you might need to adjust the input method or input data without spaces. 
  5. The program will then print the details of the students, teachers, and courses you entered.

Example Input and Output

Input:

1 Rajesh 10
1 Mrs. Sharma
1 Mathematics

Output:

Students:
Student ID: 1, Name: Rajesh, Grade: 10

Teachers:
Teacher ID: 1, Name: Mrs. Sharma

Courses:
Course ID: 1, Name: Mathematics

Comments