Document 5
Document 5
#include <vector>
#include <string>
// Student class
class Student {
public:
int id;
string name;
int age;
id = studentId;
name = studentName;
age = studentAge;
void display() {
cout << "ID: " << id << ", Name: " << name << ", Age: " << age << endl;
}
};
// StudentManagementSystem class
class StudentManagementSystem {
private:
vector<Student> students;
public:
students.push_back(newStudent);
void displayStudents() {
if (students.empty()) {
return;
if (student.id == id) {
student.display();
found = true;
break;
if (!found) {
cout << "Student with ID " << id << " not found." << endl;
auto it = students.begin();
students.erase(it);
cout << "Student with ID " << id << " deleted successfully!" << endl;
return;
++it;
cout << "Student with ID " << id << " not found." << endl;
};
// Main function
int main() {
StudentManagementSystem sms;
string name;
while (true) {
// Display menu
switch (choice) {
case 1:
// Add student
getline(cin, name);
break;
case 2:
sms.displayStudents();
break;
case 3:
// Search student by ID
sms.searchStudent(id);
break;
case 4:
// Delete student by ID
sms.deleteStudent(id);
break;
case 5:
// Exit
return 0;
default:
}
return 0;