You are on page 1of 18

A Project Report On

HOTEL MANAGEMENT SYSTEM

INDEX
1. Acknowledgement
2. Abstract
3. Class Diagrams
4. Description of the project
5. Source Code
7. Conclusion
8. Bibliography

1. ACKNOWLEDGEMENT
So, with gratitude we acknowledge all those who guided and encouraged has served a
beacon of light and crowned the effect with success.
We would like to thank Cranes Varsity International for providing an opportunity to
carry out the project successfully.
We would then like to thank M/s. ANVIwho guided and provided the technical and
moral support throughout the project.
Next we would also to thank the entire faculty for their full co-operation.
PROJECT ASSOCIATES
SHASHANK JAISWAL
RICHY TOMY
TEJDEEP DORNADULA

2. ABSTRACT
The HOTEL MANAGEMENT SYSTEM project has been designed keeping in
mind both employee and guest. For a guest to avail room he simply has to book room and
then checking in or directly checking in to the hotel. The task of maintaining the hotel rooms
lies with the employee.
The employee has to perform 3 basic tasks: (1) Adding of rooms to the database (2)
Maintain the Hotel rooms (3) Reserve rooms for guests,and (4) Generate bill at the time of
guests checking out of the hotel.
The hotel allows the guests to: (1) Checkin (2) Checkout,and (3) Book Room. These
features have been represented by functions in the program.

3. CLASS DIAGRAMS

User
- Name
- Address
- Phone_No
+ Set_details
+ Get_details

Employee
- Employee_Id
+ Set_id
+ file_write
+ get_details

Room
Room_no
Type
Status
Room_rate
Gname

Guest
-Struct ctime objin
-Struct ctime objout
+ Add_Guest

+ Add_room
+ Set_status
+ set_charges
+ get_charges
+ get_RoomNo
+get_status
+get_type
+Add_guestroom
+display_room

+ Return_Name
+checkout_guestroom
+ Disp_guest
+disp_det_chkout

4. DESCRIPTION OF PROJECT
There are total seven operations that can be performed using this programefficiently.
They are as follows:EMPLOYEE OPERATIONS:

Adding New Rooms To The Hotel: which requires assigning a room number,
type of room whether Air conditioned or non-air conditioned, current status of
room whether free or reservedand charges of room per day.

Maintaining Rooms: In this option, employee can check the all information of all
the rooms in hotel or a particular room by inputting room number and modify its
details, like changing status of room or the charges.

Reserving Room: here, the employee can check if any free rooms are available in
the hotel database and subsequently reserve it for a guest.

Generating Bill: here, at the time of guest checking out, the employee will get the
number of days the guest stayed in a particular room and generate the bill to be
paid by the guest.

GUEST OPERATIONS:

Checking In: In this guest can enter his personal details in the database if it
wishes to stay in the hotel. After inputting name, address and contact number, the
guest details will be stored for future references.

Checking Out: In this option it will first ask the guest for the room number it
wants to vacate and then the guest will be checked out of the room and checkout
time will be displayed.

Book Room: Here, guest will be asked which type of room he wishes for and if
that type of room is available then if desired checking in procedure will be
initiated.

5. SOURCE CODE
#include<iostream>
#include<iomanip>
#include<fstream>
/*function prototypes required*/
intedit_room_det(room *obj);
voidResv_Guest();
/*============================*/
using namespace std;
structctime
{
inthr;
int min;
int sec;
};
/*USER CLASS*/
class user
{
protected:
char name[20];
char address[50];

charph_no[15];
public:
voidset_details(char *n,char*ad,char*p)
{
strcpy(name,n);
strcpy(address,ad);
strcpy(ph_no,p);
}
virtual void get_details()
{
cout<<"\n Name :"<<name;
cout<<"\n Address :"<<address;
cout<<"\n phone no. :"<<ph_no;
}
};

/*EMPLOYEE CLASS*/
classemployee:public user
{
protected:
inte_id;
public:
voidSet_id(int ID)
{
e_id=ID;
}
void get_details()
{
cout<<"\n Name :"<<name;
cout<<"\n Address :"<<address;
cout<<"\n phone no. :"<<ph_no;
cout<<"\nEmployee id :"<<e_id;
}
voidfilewrite()
{
fstreamefile;
efile.open("employee.txt",ios::out|ios::app);
efile.write((char*)this,sizeof(employee));
}
};

/*GUEST CLASS*/
classguest:public user
{
structctimeobjin,objout;
public:
void Add_Guest()
{
struct tm *time1;
time_t t1;
cout<<"Enter Name"<<endl;
cin>>name;
cout<<"Enter Address"<<endl;
cin>>address;
cout<<"Enter Phone Number"<<endl;
cin>>ph_no;
t1=time(NULL);
time1=localtime(&t1);
objin.sec=time1->tm_sec;
objin.min=time1->tm_min;
objin.hr=time1->tm_hour;
}
char * Ret_Name()
{
return name;
}
voidchkout_guest_room()
{
struct tm *time1;
time_t t1;
t1=time(NULL);
time1=localtime(&t1);
objout.sec=time1->tm_sec;
objout.min=time1->tm_min;
objout.hr=time1->tm_hour;
}
voidDisp_Guest()
{
cout<<"Name:"<<name<<endl;

cout<<"Address:"<<address<<endl;
cout<<"Phone No.:"<<ph_no<<endl;
cout<<"Time::"<<objin.hr<<":"<<objin.min<<":"<<objin.sec<<endl;
}
void disp_det_chkout()
{
cout<<"Guest Checked Out"<<endl;
cout<<"Name:"<<name<<endl;
cout<<"Time::"<<objout.hr<<":"<<objout.min<<":"<<objout.sec<<endl;
}
};

/*ROOM CLASS*/
class room
{
introom_no;
char status[15];
char type[20];
floatroom_rate;
char Gname[20];
public:
voidAdd_Room()
{
cout<<"Enter Room No: "<<endl;
cin>>room_no;
cout<<"Enter Status:"<<endl;
cin>>status;
cout<<"Enter Type:"<<endl;
cin>>type;
cout<<"Enter Room Rate:"<<endl;
cin>>room_rate;
}
voidSet_Status(char *S)
{
strcpy(status,S);
cout<<"Status changed to:"<<status<<endl;
}
voidSet_Charges(float C)

{
room_rate=C;
cout<<"Room Charges Per Day set to:"<<room_rate<<endl;
}
floatGet_Charges()
{
returnroom_rate;
}
intGet_RoomNo()
{
returnroom_no;
}
char * get_status()
{
return status;
}
char *Get_Type()
{
return type;
}
voidAdd_Guest_Room()
{
cout<<"Enter Guest Name:"<<endl;
cin>>Gname;
}
void display_room()
{
cout<<"\nroom no. :"<<room_no<<endl;
cout<<"Status:"<<status<<endl;
cout<<"Type:"<<type<<endl;
cout<<"Room Rate:"<<room_rate<<endl;
}
};
/*CLASSES FINISHED*/

/*FUNCTION TO WRITE ROOM DETAILS TO DATABASE*/

voidwrite_room_database()
{
room R;
R.Add_Room();
fstreamrfile;
rfile.open("rooms.txt",ios::out|ios::app);
rfile.write((char *)&R,sizeof(R));
rfile.close();
}
/*FUNCTION TO EDIT ROOM DETAILS AND WRITING TO DATABASE*/
voidEdit_Room()
{
room R;
intRno;
fstreamrfile,tfile;
rfile.open("rooms.txt",ios::in);
tfile.open("test.txt",ios::out);
rfile.seekg(ios::beg);
cout<<"enter room number:"<<endl;
fflush(stdin);
cin>>Rno;
while(rfile.read((char *)&R,sizeof(R))!=0)
{
if(R.Get_RoomNo()==Rno)
{
cout<<"\nmatch found"<<endl;
R.display_room();
edit_room_det(&R);
tfile.write((char *)&R,sizeof(R));
}
else
tfile.write((char *)&R,sizeof(R));
}
remove("rooms.txt");
rename("test.txt","rooms.txt");
rfile.close();
tfile.close();
}

intedit_room_det(room *obj)
{

int ch3;
for(;;)
{
cout<<"\t"<<"\t"<<"\t"<<"Enter Choice To Edit"<<endl;
cout<<"\n\t"<<"\t"<<"\t"<<"1.Status"<<endl;
cout<<"\n\t"<<"\t"<<"\t"<<"2.Charges"<<endl;
cout<<"\n\t"<<"\t"<<"\t"<<"3.Exit:"<<endl;
fflush(stdin);
cin>>ch3;
switch(ch3)
{
case 1:cout<<"\t"<<"\t"<<"change status:"<<endl;
charstr[10];
cin>>str;
(*obj).Set_Status(str);
break;
case 2:cout<<"\t"<<"\t"<<"change Room charges:"<<endl;
float charges;
cin>>charges;
(*obj).Set_Charges(charges);
break;
case 3:return 0;
}
}
}
/*FUNCTION TO DISPLAY ALL ROOMS*/
voidView_Rooms()
{
room R;
fstreamrfile;
rfile.open("rooms.txt",ios::in);
rfile.seekg(ios::beg);
while(rfile.read((char *)&R,sizeof(R))!=0)
{
R.display_room();sleeP(3);
}
rfile.close();
}
/*FUNCTION TO RESERVE A ROOM FOR GUEST*/

voidResv_Room()
{
room R;
charstr[10];
fstreamrfile,tfile;
rfile.open("rooms.txt",ios::in);
rfile.seekg(ios::beg);
cout<<"enter room status"<<endl;
fflush(stdin);
cin>>str;
while(rfile.read((char *)&R,sizeof(R))!=0)
{
if(strcmp(R.get_status(),str)==0)
{
R.display_room();
}
}
rfile.close();
Resv_Guest();
}
/*SUB FUNCTION OF RESERVING GUEST*/
voidResv_Guest()
{
fstreamfroom,troom;
room R;
intRno;
cout<<"Enter Which Room You Want To Reserve:"<<endl;
cin>>Rno;
froom.open("rooms.txt",ios::in);
troom.open("test.txt",ios::out);
while(froom.read((char *)&R,sizeof(R))!=0)
{
if(R.Get_RoomNo()==Rno)
{
R.display_room();
R.Set_Status("reserve");
R.Add_Guest_Room();
troom.write((char *)&R,sizeof(R));
}
else
troom.write((char *)&R,sizeof(R));

}
froom.close();
troom.close();
remove("rooms.txt");
rename("test.txt","rooms.txt");
}

/*FUNCTION TO GENERATE BILL*/


voidGenerate_Bill()
{
fstreamfroom,troom;
room R;
intRno,Dno;
float Rate;
cout<<"Enter Which Room You Want To GenarateBiLL For:"<<endl;
cin>>Rno;
cout<<"No. Of Days Stayed:"<<endl;
cin>>Dno;
froom.open("rooms.txt",ios::in);
troom.open("test.txt",ios::out);
while(froom.read((char *)&R,sizeof(R))!=0)
{
if(R.Get_RoomNo()==Rno)
{
R.display_room();
cout<<"==========="<<endl;
Rate=R.Get_Charges();
R.Set_Status("free");
troom.write((char *)&R,sizeof(R));
cout<<"Total Bill To Be Paid:"<<endl;
cout<<Rate*Dno<<endl;
}
else
troom.write((char *)&R,sizeof(R));
}
froom.close();
troom.close();
remove("rooms.txt");
rename("test.txt","rooms.txt");

}
/*EMPLOYEE MENU*/
intemp_menu()
{
for(;;)
{
cout<<"\t"<<"\t"<<"\t"<<"\t"<<"Employee Menu"<<endl;
cout<<"\t"<<"\t"<<"\t"<<"\t"<<"=============="<<endl;
cout<<"\n\t"<<"\t"<<"\t"<<"\t"<<"1.Add Room"<<endl;
cout<<"\n\t"<<"\t"<<"\t"<<"\t"<<"2.View Rooms"<<endl;
cout<<"\n\t"<<"\t"<<"\t"<<"\t"<<"3.Edit Room"<<endl;
cout<<"\n\t"<<"\t"<<"\t"<<"\t"<<"4.Reserve Room"<<endl;
cout<<"\n\t"<<"\t"<<"\t"<<"\t"<<"5.Generate Bill"<<endl;
cout<<"\n\t"<<"\t"<<"\t"<<"\t"<<"6.Exit"<<endl;
int ch1;
cin>>ch1;
switch(ch1)
{
case 1:write_room_database();
break;
case 2:View_Rooms();
break;
case 3:Edit_Room();
break;
case 4:Resv_Room();
break;
case 5:Generate_Bill();
break;
case 6:return 0;
}
}
}
/*GUEST FUNCTIONS*/
/*FUNCTION TO CHECK IN GUEST*/

voidcheckin_guest()
{
guest G;
G.Add_Guest();
G.Disp_Guest();
cout<<"Guest Checked In"<<endl;
R.Set_Status("reserve");
fstreamgfile;
gfile.open("guests.txt",ios::out|ios::app);
gfile.write((char *)&G,sizeof(G));
gfile.close();
}

/*BOOKING ROOM FUNCTION*/


voidbook_room()
{
charrtype[10];
cout<<"Enter Room Type You Want:(AC/NAC)"<<endl;
cin>>rtype;
room R;
char ch4;
fstreamfroom,troom;
froom.open("rooms.txt",ios::in);
while(froom.read((char *)&R,sizeof(R))!=0)
{
if(strcmp(R.Get_Type(),rtype)==0)
{
cout<<"Rooms Available"<<endl;
cout<<"Charges:"<<R.Get_Charges()<<endl;
}
}
cout<<"Do You Want To Book Room?(Y/N)"<<endl;
cin>>ch4;
if(ch4=='y'||ch4=='Y')
{
checkin_guest();
}
froom.close();

}
/*GUEST CHECKOUT FUNCTION*/
voidcheckout_guest()
{
guest G;
charstr[20];
cout<<"Enter Name To Find:"<<endl;
cin>>str;
fstreamfguest,tguest;
fguest.open("guests.txt",ios::in);
tguest.open("test.txt",ios::out);
while(fguest.read((char *)&G,sizeof(G))!=0)
{
if(strcmp(G.Ret_Name(),str)==0)
{
G.chkout_guest_room();
G.disp_det_chkout();
tguest.write((char *)&G,sizeof(G));
}
else
tguest.write((char *)&G,sizeof(G));
}
fguest.close();
tguest.close();
remove("guests.txt");
rename("test.txt","guests.txt");
}
/*GUEST MENU*/
intguest_menu()
{
for(;;)
{
cout<<"\t"<<"Guest Menu"<<endl;
cout<<"\t"<<"1.Check In"<<endl;
cout<<"\t"<<"2.Check Out"<<endl;
cout<<"\t"<<"3.Book Room"<<endl;
cout<<"\t"<<"4.Exit"<<endl;
int ch2;
cin>>ch2;
switch(ch2)
{
case 1:checkin_guest();
break;

case 2:checkout_guest();
break;
case 3:book_room();
break;
case 4:return 0;
}
}
}
/* MAIN PROGRAM*/
int main()
{
employee e1(1,"shashank","delhi","123"),e2(2,"tejdeep","andhra","456");
e1.filewrite();
e2.filewrite();
intch;
for(;;)
{
cout<<"\t"<<"\t"<<"\t"<<"\t"<<"Hotel Management System"<<endl;
cout<<"\t"<<"\t"<<"\t"<<"\t"<<"======================="<<endl;
cout<<"\n\t"<<"\t"<<"\t"<<"\t"<<"Choose option"<<endl;
cout<<"\n\t"<<"\t"<<"\t"<<"\t"<<"1.EMPLOYEE"<<endl;
cout<<"\n\t"<<"\t"<<"\t"<<"\t"<<"2.GUEST"<<endl;
cout<<"\n\t"<<"\t"<<"\t"<<"\t"<<"3.EXIT"<<endl;
cin>>ch;
switch(ch)
{
case 1:emp_menu();
break;
case 2:guest_menu();
break;
case 3:exit(0);
}
}
}
/* END OF PROJECT*/

6. CONCLUSION
The hotel management system project was implemented and executed
successfully.

7. BIBLIOGRAPHY
1. C++ primer
2. Google
3. Wikipedia

You might also like