Hotel Management System Report

23
A Project Report On “HOTEL MANAGEMENT SYSTEM” Submitted By SHASHANK JAISWAL RICHY TOMY TEJDEEP Batch No: RTOS-348 Under the guidance of M/s. ANVI An ISO 9001 Company Cranes Software International Ltd. (Cranes Varsity - Training Division) # 5, Service Road, Domlur Layout, Airport Road, Bangalore-560071. Ph: 25352636/37, www.cranessoftware.c om

description

Hotel management system created using C++

Transcript of Hotel Management System Report

Page 1: Hotel Management System Report

A Project Report On

“HOTEL MANAGEMENT SYSTEM”

Submitted By

SHASHANK JAISWALRICHY TOMY

TEJDEEP

Batch No: RTOS-348

Under the guidance of M/s. ANVI

An ISO 9001 Company

Cranes Software International Ltd.(Cranes Varsity - Training Division)# 5, Service Road, Domlur Layout,Airport Road, Bangalore-560071.

Ph: 25352636/37, www.cranessoftware.com

Page 2: Hotel Management System Report

INDEX

1. Acknowledgement

2. Abstract 3. Class Diagrams

4. Description of the project

5. Source Code

7. Conclusion

8. Bibliography

1. ACKNOWLEDGEMENT

Page 3: Hotel Management System Report

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. ANVI who 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

Page 4: Hotel Management System Report

User - Name

- Address

- Phone_No

+ Set_details

+ Get_details

Employee

- Employee_Id

+ Set_id

+ file_write

+ get_details

Guest -Struct ctime objin

-Struct ctime objout

+ Add_Guest

+ Return_Name

+checkout_guestroom

+ Disp_guest

+disp_det_chkout

Room- Room_no- Type- Status- Room_rate- Gname

+ Add_room

+ Set_status

Page 5: Hotel Management System Report

4. DESCRIPTION OF PROJECT

There are total seven operations that can be performed using this program efficiently.

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 reserved and 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.

Room- Room_no- Type- Status- Room_rate- Gname

+ Add_room

+ Set_status

Page 6: Hotel Management System Report

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*/int edit_room_det(room *obj);void Resv_Guest();/*============================*/

using namespace std;

struct ctime{

int hr; int min; int sec;};

/*USER CLASS*/

class user { protected: char name[20]; char address[50]; char ph_no[15]; public: void set_details(char *n,char*ad,char*p) { strcpy(name,n);

Page 7: Hotel Management System Report

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*/

class employee:public user {

protected: int e_id;

public: void Set_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; }

void filewrite() { fstream efile; efile.open("employee.txt",ios::out|ios::app); efile.write((char*)this,sizeof(employee)); } };

/*GUEST CLASS*/

Page 8: Hotel Management System Report

class guest:public user { struct ctime objin,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;}

void chkout_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;}

void Disp_Guest(){ cout<<"Name:"<<name<<endl; cout<<"Address:"<<address<<endl; cout<<"Phone No.:"<<ph_no<<endl; cout<<"Time::"<<objin.hr<<":"<<objin.min<<":"<<objin.sec<<endl;

}

Page 9: Hotel Management System Report

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 {

int room_no; char status[15]; char type[20]; float room_rate; char Gname[20]; public: void Add_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;}

void Set_Status(char *S){ strcpy(status,S); cout<<"Status changed to:"<<status<<endl;}

void Set_Charges(float C){ room_rate=C; cout<<"Room Charges Per Day set to:"<<room_rate<<endl;

Page 10: Hotel Management System Report

}

float Get_Charges(){ return room_rate;}

int Get_RoomNo(){ return room_no;}

char * get_status(){ return status;}

char *Get_Type(){ return type;}

void Add_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*/

void write_room_database(){ room R;

Page 11: Hotel Management System Report

R.Add_Room(); fstream rfile; 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*/

void Edit_Room(){

room R; int Rno; fstream rfile,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();

}

int edit_room_det(room *obj){ int ch3; for(;;) {

Page 12: Hotel Management System Report

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; char str[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*/

void View_Rooms() {

room R; fstream rfile; 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*/

void Resv_Room() {

Page 13: Hotel Management System Report

room R; char str[10]; fstream rfile,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*/

void Resv_Guest(){ fstream froom,troom; room R; int Rno; 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();

Page 14: Hotel Management System Report

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

}

/*FUNCTION TO GENERATE BILL*/

void Generate_Bill() { fstream froom,troom; room R; int Rno,Dno; float Rate; cout<<"Enter Which Room You Want To Genarate BiLL 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"); }

Page 15: Hotel Management System Report

/*EMPLOYEE MENU*/

int emp_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*/

void checkin_guest(){

Page 16: Hotel Management System Report

guest G; G.Add_Guest(); G.Disp_Guest(); cout<<"Guest Checked In"<<endl;

R.Set_Status("reserve"); fstream gfile; gfile.open("guests.txt",ios::out|ios::app); gfile.write((char *)&G,sizeof(G)); gfile.close();}

/*BOOKING ROOM FUNCTION*/

void book_room(){ char rtype[10]; cout<<"Enter Room Type You Want:(AC/NAC)"<<endl; cin>>rtype; room R; char ch4; fstream froom,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();}

Page 17: Hotel Management System Report

/*GUEST CHECKOUT FUNCTION*/

void checkout_guest(){ guest G; char str[20]; cout<<"Enter Name To Find:"<<endl; cin>>str; fstream fguest,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*/

int guest_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;

Page 18: Hotel Management System Report

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(); int ch;

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*/

Page 19: Hotel Management System Report

6. CONCLUSIONThe hotel management system project was implemented and executed successfully.

7. BIBLIOGRAPHY

1. C++ primer2. Google3. Wikipedia