#include <iostream>
#include <string>
using namespace std;
// Define a class for the Hostel Accommodation System
class Hostel {
private:
    string studentNames[100]; // Array to store student names
    int studentIDs[100];       // Array to store student IDs
    string roomNumbers[100];   // Array to store room numbers
    int count;                 // To keep track of the number of students
public:
    // Constructor to initialize the count
    Hostel() {
        count = 0;
    }
    // Function to add student details
    void addStudent() {
        if (count < 100) {
            cout << "Enter Student Name: ";
            cin >> studentNames[count];
            cout << "Enter Student ID: ";
            cin >> studentIDs[count];
            cout << "Enter Room Number: ";
            cin >> roomNumbers[count];
            count++;
            cout << "Student added successfully!" << endl;
        } else {
            cout << "Hostel is full! Cannot add more students." << endl;
        }
    }
    // Function to display all student details
    void displayStudents() {
        if (count == 0) {
            cout << "No students are currently added." << endl;
        } else {
            for (int i = 0; i < count; i++) {
                 cout << "\nStudent " << i + 1 << ":\n";
                 cout << "Name: " << studentNames[i] << endl;
                 cout << "Student ID: " << studentIDs[i] << endl;
                 cout << "Room Number: " << roomNumbers[i] << endl;
            }
        }
    }
    // Function to search student by ID
    void searchStudentByID(int id) {
        bool found = false;
        for (int i = 0; i < count; i++) {
            if (studentIDs[i] == id) {
                cout << "\nStudent Found:\n";
                cout << "Name: " << studentNames[i] << endl;
                cout << "Student ID: " << studentIDs[i] << endl;
                cout << "Room Number: " << roomNumbers[i] << endl;
                found = true;
                break;
            }
        }
        if (!found) {
            cout << "Student with ID " << id << " not found." << endl;
        }
    }
    // Function to delete a student by ID
    void deleteStudentByID(int id) {
        bool found = false;
        for (int i = 0; i < count; i++) {
            if (studentIDs[i] == id) {
                // Shift the elements to delete the student
                for (int j = i; j < count - 1; j++) {
                    studentNames[j] = studentNames[j + 1];
                    studentIDs[j] = studentIDs[j + 1];
                    roomNumbers[j] = roomNumbers[j + 1];
                }
                count--;
                cout << "Student with ID " << id << " deleted successfully!" <<
endl;
                found = true;
                break;
            }
        }
        if (!found) {
            cout << "Student with ID " << id << " not found." << endl;
        }
    }
};
int main() {
    Hostel hostel;
    int choice, id;
    while (true) {
        cout << "\nHostel Accommodation System\n";
        cout << "1. Add Student\n";
        cout << "2. Display Students\n";
        cout << "3. Search Student by ID\n";
        cout << "4. Delete Student by ID\n";
        cout << "5. Exit\n";
        cout << "Enter your choice: ";
        cin >> choice;
        switch (choice) {
        case 1:
            hostel.addStudent();
            break;
        case 2:
            hostel.displayStudents();
            break;
        case 3:
            cout << "Enter Student ID to search: ";
            cin >> id;
            hostel.searchStudentByID(id);
            break;
        case 4:
            cout << "Enter Student ID to delete: ";
            cin >> id;
            hostel.deleteStudentByID(id);
            break;
        case 5:
            cout << "Exiting program. Thank you!" << endl;
            return 0;
        default:
            cout << "Invalid choice! Please try again." << endl;
        }
    }
    return 0;
}