Hostel Allocation System C++ Project
Hostel Allocation System C++ Project
Hostel Allocation System C++ Project
INTRODUCTION:
This Project work intends to address some of the problems encountered in the
allocation of hostels to students manually. The growing number of students in
higher institutions posed a lot of accommodation problems on the part of
students and School Management. Some of the problem caused includes: Few
hostels that exist in the University are not Properly managed, Statistic of rooms
required to match the growing number of students are farfetched, Student pays
fee for hostel and may end up not getting rooms because of lack of bed, Hostel
administrators cannot give accurate information of the occupancy of a particular
room. The system designed will keep track of all the available rooms, their
occupants and funds generated from hostel fees. The growing number of
students in higher institutions all over the world has posed a lot of
accommodation problem on the part of students and school management.
Students at the beginning of each session waste half of the semester looking for
accommodation.
BENEFITS:
Hostel management simplified
Rooms and bed allocation made easy
Complete Mess management
Disciplinary log maintenance
Setting up fees as per the facilities in the hostel
Hostel and mess fee integrated with fees management module for
automated fee calculation
Provision for Hostel vacating / change management
Final account details
Daily updates to parents on hostel attendance
LIMITATIONS
Some of the constraints encountered during this project design include the
following:
Time Consuming
Inaccuracy of data
More Human Error
Low security
Difficult to handle
SOURCE CODE
#include<iostream>
#include<fstream>
#include<stdio.h>
class hostel
int room_no;
char name[30];
char address[50];
char phone[10];
public:
int main_menu();
int add();
int display();
int rooms();
int edit();
int check(int);
int modify(int);
int delete_rec(int);
};
int hostel::main_menu()
int choice=0;
while(choice!=5)
cout<<"\n\t\t\t\t*************";
cout<<"\n\t\t\t\t*************";
cout<<"\n\n\n\t\t\t1.Book A Room";
cout<<"\n\t\t\t2.student Record";
cout<<"\n\t\t\t3.Rooms Allotted";
cout<<"\n\t\t\t4.Edit Record";
cout<<"\n\t\t\t5.Exit";
cin>>choice;
switch(choice)
case 1: add();
break;
case 2: display();
break;
case 3: rooms();
break;
case 4: edit();
break;
case 5: break;
default:
cout<<"\n\n\t\t\tWrong choice!!!";
return 0;
system("pause");
}
int hostel::add()
int r,flag;
ofstream fout("Record.txt",ios::app);
cout<<"\n **********************";
cin>>r;
flag=check(r);
if(flag)
else
room_no=r;
cin>>address;
cin>>phone;
cout<<endl;
fout.write((char*)this,sizeof(*this));
system("pause");
fout.close();
return 0;
int hostel::display()
ifstream fin("Record.txt",ios::in);
int r;
cout<<"\n Enter room no: ";
cin>>r;
while(!fin.eof())
fin.read((char*)this,sizeof(*this));
if(room_no = r)
cout<<"\n ****************";
else{
system("pause");
fin.close();
return 0;
}}
int hostel::rooms()
ifstream fin("Record.txt",ios::in);
cout<<"\n\t\t\t*********************";
while(!fin.eof())
fin.read((char*)this,sizeof(*this));
cout<<"\n\n "<<room_no<<"\t\t"<<name;
cout<<"\t\t"<<address<<"\t\t"<<phone;
}
system("pause");
fin.close();
return 0;
int hostel::edit()
int choice,r;
cout<<"\n *********";
cin>>choice;
switch(choice)
case 1: modify(r);
break;
case 2: delete_rec(r);
break;
return 0;
system("pause");
int hostel::check(int r)
int flag=0;
ifstream fin("Record.txt",ios::in);
while(!fin.eof())
fin.read((char*)this,sizeof(*this));
if(room_no==r)
flag=1;
break;
fin.close();
return(flag);
int hostel::modify(int r)
fstream file("Record.txt",ios::in|ios::out|ios::binary);
flag=0;
while(!file.eof())
pos=file.tellg();
file.read((char*)this,sizeof(*this));
if(room_no==r)
cout<<"\n *****************";
cin>>name;
cin>>address;
cin>>phone;
file.seekg(pos);
file.write((char*)this,sizeof(*this));
flag=1;
break;
}}
if(flag==0)
cout<<"\n Sorry Room no. not found or vacant!!";
file.close();
return 0;
int hostel::delete_rec(int r)
int flag=0;
char ch;
ifstream fin("Record.txt",ios::in);
ofstream fout("temp.txt",ios::out);
while(!fin.eof())
fin.read((char*)this,sizeof(*this));
if(room_no==r)
if(ch=='n')
fout.write((char*)this,sizeof(*this));
flag=1;
else
fout.write((char*)this,sizeof(*this));
fin.close();
fout.close();
if(flag==0)
else
remove("Record.txt");
rename("temp.txt","Record.txt");
return 0;
}
int main()
hostel h;
cout<<"\n\t\t\t****************************";
cout<<"\n\t\t\t****************************";
system("pause");
h.main_menu();
system("pause");
OUTPUT
CONCLUSION
This project offers the user to enter the data in simple and interactive manner.
User is provided with the option of only viewing the records he has entered
earlier. Data storage and retrieval will become faster and easier to maintain.