Intro – Student Management System
A Student Management System (SMS) is a software which is used for manage the student data, such as registration, attendance, grades, and other related information. Implementing a basic SMS in C++ involves designing data structures to store student records, implementing functionalities to add, delete, modify, and display student information and handling user interactions through a command line interfaces.
Key Features of Project
- Student Record:
- Each student record typically includes attributes such as student ID, name, age, gender, course enrolled, grades, attendance, etc.
- Functionalities:
- Add Student: Allows adding a new student record to the system.
- Delete Student: Deletes an existing student record based on student ID.
- Update Student: Modifies information (e.g., grades, attendance) of an existing student.
- Search Student: Searches for a student record based on student ID or name.
- Display All Students: Displays all student records stored in the system.
- Data Management:
- Utilizes data structures like arrays, linked lists, or dynamic arrays (vectors) to store and manage student records.
- Implements file handling for data persistence (optional).
Code Of the Project
Here is the Project Codes,
#include <iostream> #include <vector> #include <algorithm> // for std::find_if class Student { private: int studentID; std::string name; int age; char gender; std::string course; float grade; public: Student(int id, const std::string& n, int a, char g, const std::string& c, float gr) : studentID(id), name(n), age(a), gender(g), course(c), grade(gr) {} int getStudentID() const { return studentID; } std::string getName() const { return name; } int getAge() const { return age; } char getGender() const { return gender; } std::string getCourse() const { return course; } float getGrade() const { return grade; } void displayDetails() const { std::cout << "Student ID: " << studentID << "\n"; std::cout << "Name: " << name << "\n"; std::cout << "Age: " << age << "\n"; std::cout << "Gender: " << gender << "\n"; std::cout << "Course: " << course << "\n"; std::cout << "Grade: " << grade << "\n"; std::cout << "------------------\n"; } }; class StudentManagementSystem { private: std::vector<Student> students; int nextStudentID = 1; // Start student IDs from 1 and increment public: void addStudent(const std::string& name, int age, char gender, const std::string& course, float grade) { students.emplace_back(nextStudentID++, name, age, gender, course, grade); } void deleteStudent(int studentID) { auto it = std::find_if(students.begin(), students.end(), [studentID](const Student& s) { return s.getStudentID() == studentID; }); if (it != students.end()) { students.erase(it); std::cout << "Student with ID " << studentID << " deleted.\n"; } else { std::cout << "Student with ID " << studentID << " not found.\n"; } } void updateStudent(int studentID, float newGrade) { auto it = std::find_if(students.begin(), students.end(), [studentID](const Student& s) { return s.getStudentID() == studentID; }); if (it != students.end()) { it->grade = newGrade; std::cout << "Grade updated for student with ID " << studentID << ".\n"; } else { std::cout << "Student with ID " << studentID << " not found.\n"; } } void searchStudent(int studentID) const { auto it = std::find_if(students.begin(), students.end(), [studentID](const Student& s) { return s.getStudentID() == studentID; }); if (it != students.end()) { it->displayDetails(); } else { std::cout << "Student with ID " << studentID << " not found.\n"; } } void displayAllStudents() const { for (const auto& student : students) { student.displayDetails(); } } }; int main() { StudentManagementSystem sms; // Adding some initial students sms.addStudent("Alice", 20, 'F', "Computer Science", 85.5); sms.addStudent("Bob", 21, 'M', "Mathematics", 78.3); sms.addStudent("Charlie", 19, 'M', "Physics", 92.0); int choice; int studentID; std::string name; int age; char gender; std::string course; float grade; do { std::cout << "\nStudent Management System Menu\n"; std::cout << "1. Add Student\n"; std::cout << "2. Delete Student\n"; std::cout << "3. Update Student Grade\n"; std::cout << "4. Search Student\n"; std::cout << "5. Display All Students\n"; std::cout << "6. Exit\n"; std::cout << "Enter your choice: "; std::cin >> choice; switch (choice) { case 1: std::cout << "Enter name, age, gender (M/F), course, grade: "; std::cin >> name >> age >> gender >> course >> grade; sms.addStudent(name, age, gender, course, grade); std::cout << "Student added successfully.\n"; break; case 2: std::cout << "Enter student ID to delete: "; std::cin >> studentID; sms.deleteStudent(studentID); break; case 3: std::cout << "Enter student ID and new grade: "; std::cin >> studentID >> grade; sms.updateStudent(studentID, grade); break; case 4: std::cout << "Enter student ID to search: "; std::cin >> studentID; sms.searchStudent(studentID); break; case 5: std::cout << "Displaying all students:\n"; sms.displayAllStudents(); break; case 6: std::cout << "Exiting...\n"; break; default: std::cout << "Invalid choice. Please try again.\n"; } } while (choice != 6); return 0; }