Report1 of Oop Final
Report1 of Oop Final
Micro-Project Report
Hostel Management System
1.0 Rational
The Hostel Management System is a project that rationalizes the process of managing student
information within a hostel. It integrates the use of Object-Oriented Programming (OOP) principles to
create a modular, scalable, and efficient system for handling various operations related to hostel
administration. The rationale behind this system can be explained by looking at the need for such a
system, the benefits it offers, and how it meets specific requirements in a real-world scenario.
• This code is a C++ program for a Hostel Management System. Let's break down thefunctionality
and key components of the code:
• Header Files: The code includes several header files: - iostream: For input and outputoperations.
-conio.h: For console input/output operations, although this header is
non-standard and might not be available in all compilers.
-fstream: For file input/output operations.
-string: For string operations.
-string.h: This header file is included, but it's not used in the code.
• This line brings the entire ‘std’ namespace into the current scope, allowing the use ofstandard
C++ library functions without prefixing them with 'std::’.
• Class Declaration: ‘class HostelDB’ defines a class named `HostelDB` which is used tomanage
functions, a constructor.
• Structure: ‘Hostel: {}’ is a structure that initializes the student id, rooms, fees, contacts,address,
name.
• Member Functions: The class ‘HostelDB’ contains several member functions:
4.2 Implementation/Coding
#include <iostream>
#include <vector>
#include <string>
using namespace std;
class Student
{
public:
int student_id;
string name;
string room_number;
bool fee_status;
string complaints;
student_id = id;
name = student_name;
room_number = room;
fee_status = false;
complaints = "No Complaints";
}
void display()
{
cout << "Student ID: " << student_id << endl;
cout << "Name: " << name << endl;
cout << "Room Number: " << room_number << endl;
cout << "Fee Status: " << (fee_status ? "Paid" : "Unpaid") << endl;
cout << "Complaints: " << complaints << endl;
cout << "--------------------------" << endl;
}
};
class HostelManagementSystem
{
vector<Student> students;
public:
void insert_student(int id, string name, string room_number)
{
students.push_back(Student(id, name, room_number));
cout << "Student " << name << " added successfully!" << endl;
}
void display_students()
{
if (students.empty())
{
cout << "No students found." << endl;
return;
}
for (const auto &student : students) {
student.display();
}
}
students[i].display();
return i;
}
}
cout << "Student with ID " << id << " not found." << endl;
return -1;
}
void menu()
{
HostelManagementSystem hms;
int choice, id;
string name, room, complaint;
while (true)
{
cout << "\n--- Hostel Management System ---" << endl;
cout << "1. Insert Student" << endl;
cout << "2. Display All Students" << endl;
cout << "3. Search Student" << endl;
cout << "4. Modify Student Details" << endl;
cout << "5. Delete Student" << endl;
cout << "6. Pay Fees" << endl;
cout << "7. Add Complaint" << endl;
cout << "8. Exit" << endl;
cout << "Enter your choice (1-8): ";
cin >> choice;
switch (choice)
{
case 1:
cout << "Enter Student ID: ";
cin >> id;
cout << "Enter Student Name: ";
cin.ignore();
getline(cin, name);
cout << "Enter Room Number: ";
getline(cin, room);
hms.insert_student(id, name, room);
break;
case 2:
hms.display_students();
break;
case 3:
cout << "Enter Student ID to search: ";
cin >> id;
hms.search_student(id);
break;
case 4:
cout << "Enter Student ID to modify: ";
cin >> id;
cout << "Enter new name (leave blank to keep unchanged): ";
cin.ignore();
getline(cin, name);
cout << "Enter new room number (leave blank to keep unchanged): ";
getline(cin, room);
Department of Computer Engineering Page |
5
Hostel Management System
case 5:
cout << "Enter Student ID to delete: ";
cin >> id;
hms.delete_student(id);
break;
case 6:
cout << "Enter Student ID to pay fees: ";
cin >> id;
hms.pay_fees(id);
break;
case 7:
cout << "Enter Student ID to add a complaint: ";
cin >> id;
cout << "Enter the complaint: ";
cin.ignore();
getline(cin, complaint);
hms.add_complaint(id, complaint);
break;
case 8:
hms.exit_system();
break;
default:
cout << "Invalid choice, please try again!" << endl;
break;
}
}
}
int main()
{
menu();
return 0;
}
The development of the Hostel Management System in C++ provides a comprehensive solution to
the challenges faced in managing hostel facilities within educational institutions and other
organizations. Through the implementation of various features such as student registration, room
allocation, fee management, staff management, reporting, and security measures, the system offers an
efficient and user-friendly platform for hostel administrators to streamline their administrative
tasks.By leveraging the power of C++ programming language, the system ensures robustness,
performance, and scalability, making it suitable for deployment in diverse environments.