You are on page 1of 22

We Hereby declare that the project work entitled

Hotel Management, submitted to Department of


Computer Science, Gulf Indian High School, Dubai is
prepared by us. All the coding are results of our
personal efforts.

Every project big or small is successful largely due to the


effort of a number of wonderful people who have always given
their valuable advice or lent a helping hand.
We sincerely appreciate the inspiration, support and
guidance of all those people who have been instrumental in
making this project a great success.
At this juncture, we feel deeply honored in expressing my
sincere thanks to Mrs Anita (respected teacher) for the
confidence bestowed in us and entrusting our project
entitled Hotel Management and providing valuable insights
leading to the successful completion of our project.
Last but not the least we place a deep sense of gratitude to
our family members and our friends who have been constant
source of inspiration during the preparation of this project
work.

As the humans evolved to modernity, our


travel and amusement needs have also grown. In
modern day, the hotel stays have become one of
our very best personal choices when it comes to
travelling and leisure purpose. And here I am glad to
introduce this program which serves as a basic
necessity of a hotel service. Hence the name Hotel
Management serves the idea greatly. This program
is designed in such a way that a valuable customer
can book a respected room on his convenience. This
program also helps the hotel authorities to keep a
track on the customers, their bookings, and an eye
on their details, thus making it safety model
application too.
Hence, in all the aspects, this program is a very
mandatory and a step to a safer and smarter
management system.

-----------------------------------------------------------------------------------#include<iostream> : For I/O Operations


-----------------------------------------------------------------------------------#include<conio.h> : For clrscr() and getch()
-----------------------------------------------------------------------------------#include<fstream> : For File Handling
-----------------------------------------------------------------------------------#include<stdio.h> : For Standard I/O Operations
-----------------------------------------------------------------------------------#include<dos.h>
: For using System Commands
-----------------------------------------------------------------------------------#include<stdlib.h> : For using Standard Library Operations
-----------------------------------------------------------------------------------#include<string>
: For using String Operations
------------------------------------------------------------------------------------

------------------------------------------------------------------------------------

RECORD.DAT
TEMP.DAT
------------------------------------------------------------------------------------

HOTEL MANAGEMENT.CPP
------------------------------------------------------------------------------------

MAIN.OBJ
------------------------------------------------------------------------------------

MAIN.EXE
------------------------------------------------------------------------------------

------------------------------------------------------------------------------------

1. To go to the Main Menu


2. To Book a Room
3. To Check the Allotted Rooms
4. To Modify the Records
5. To Delete the Records
6. Exit
------------------------------------------------------------------------------------

#include<iostream>
#include<conio.h>
#include<fstream>
#include<stdio.h>
#include<dos.h>
#include<stdlib.h>
#include<string>
using namespace std;
class hotel
{
int room_no;
char name[20];
char phone[10];

//Customer Name

public:
void main_menu();
void book();
void display();
void alloted_rooms();
void edit();
void modify(int);
int check(int);
void delete_rec(int);

//Function
//Function
//Function
//Function
//Function
//Function
//Function
//Function

to
to
to
to
to
to
to
to

Display the Main Menu


Book A Room
display the customer record
display allotted rooms
edit the customer record
Modify Customer Record
check room status
delete the record

};
void hotel::main_menu()
{
int choice;
while(choice!=5)
{
system("cls");
//Function to Clear The Screen
cout<<"\n\t\t\t\t-------------";
cout<<"\n\t\t\t\t -MAIN MENU- ";
cout<<"\n\t\t\t\t-------------";
cout<<"\n\n\n\t\t\t1.Book A Room";
cout<<"\n\t\t\t2.Customer Record";
cout<<"\n\t\t\t3.Rooms Allotted";
cout<<"\n\t\t\t4.Edit Record";
cout<<"\n\t\t\t5.Exit";
cout<<"\n\n\t\t\tEnter Your Choice: ";
cin>>choice;
switch(choice)
{
case 1: book();

break;
case 2: display();
break;
case 3: alloted_rooms();
break;
case 4: edit();
break;
case 5: break;
default:
{
cout<<"\n\n\t\t\tWrong choice!!!";
cout<<"\n\t\t\tPress any key to continue!!!";
getch();
}
}
}
}
void hotel::book()
{
system("cls");
int r,flag;
ofstream fout("Record.dat",ios::binary);
cout<<"\n Enter Customer Details";
cout<<"\n ----------------------";
cout<<"\n Room no: ";
cin>>r;
flag=check(r);
if(flag)
cout<<"\n Sorry..!!!Room is already booked";
else
{
room_no=r;
cout<<" Name: ";
cin>>name;
cout<<" Phone No: ";
cin>>phone;
fout.write((char*)this,sizeof(hotel));
cout<<"\n Room is booked by "<<name;
}
cout<<"\n Press any key to continue.....!!";
getch();
fout.close();
}
void hotel::display()
{
system("cls");
ifstream fin("Record.dat",ios::in);
int r,flag;
cout<<"\n Enter room no: ";
cin>>r;
while(!fin.eof())
//To Check End of File Has Reached
{
fin.read((char*)this,sizeof(hotel));
if(room_no==r)
{

system("cls");
cout<<"\n Customer Details";
cout<<"\n ----------------";
cout<<"\n\n Room no: "<<room_no;
cout<<"\n Name: "<<name;
cout<<"\n Phone no: "<<phone;
flag=1;
break;
}
}
if(flag==0)
cout<<"\n Sorry Room no. not found or vacant....!!";
cout<<"\n\n Press any key to continue....!!";
getch();
fin.close();
}
void hotel::alloted_rooms()
{
system("cls");
ifstream fin("Record.dat",ios::in);
cout<<"\n\t\t\t
List Of Rooms Allotted";
cout<<"\n\t\t\t
----------------------";
cout<<"\n\n Room No.\tName\t\tPhone No.\n";
while(!fin.eof())
{
fin.read((char*)this,sizeof(hotel));
cout<<"\n\n "<<room_no<<"\t\t"<<name;
cout<<"\t\t"<<phone;
}
cout<<"\n\n\n\t\t\tPress any key to continue";
getch();
fin.close();
}
void hotel::edit()
{
system("cls");
int choice,r;
cout<<"\n EDIT MENU";
cout<<"\n ---------";
cout<<"\n\n 1.Modify Customer Record";
cout<<"\n 2.Delete Customer Record";
cout<<"\n Enter your choice: ";
cin>>choice;
system("cls");
cout<<"\n Enter room no: " ;
cin>>r;
switch(choice)
{
case 1: modify(r);
break;
case 2: delete_rec(r);
break;
default: cout<<"\n Wrong Choice";

}
cout<<"\n Press any key to continue";
getch();
}
int hotel::check(int r)
{
int flag=0;
ifstream fin("Record.dat",ios::in);
while(!fin.eof())
{
fin.read((char*)this,sizeof(hotel));
if(room_no==r)
{
flag=1;
break;
}
}
fin.close();
return(flag);
}
void hotel::modify(int r)
{
long pos,flag=0;
fstream file("Record.dat",ios::in|ios::out|ios::binary);
while(!file.eof())
{
pos=file.tellg();
file.read((char*)this,sizeof(hotel));
if(room_no==r)
{
cout<<"\n Enter New Details";
cout<<"\n -----------------";
cout<<"\n Name: ";
cin>>name;
cout<<" Phone no: ";
cin>>phone;
file.seekg(pos);
file.write((char*)this,sizeof(hotel));
cout<<"\n Record is modified";
flag=1;
break;
}
}
if(flag==0)
cout<<"\n Sorry Room no. not found or vacant";
file.close();
}
void hotel::delete_rec(int r)
{
int flag=0;
char ch;
ifstream fin("Record.dat",ios::in);
ofstream fout("temp.dat",ios::out);
while(!fin.eof())
{
fin.read((char*)this,sizeof(hotel));

if(room_no==r)
{
cout<<"\n Name: "<<name;
cout<<"\n Phone No: "<<phone;
cout<<"\n\n Do you want to delete this record(y/n): ";
cin>>ch;
if(ch=='n')
fout.write((char*)this,sizeof(hotel));
flag=1;
}
else
fout.write((char*)this,sizeof(hotel));
}
fin.close();
fout.close();
if(flag==0)
cout<<"\n Sorry room no. not found or vacant...!!";
else
{
remove("Record.dat");
//Function to Remove Record of Customer
rename("temp.dat","Record.dat");
//Function to Rename Record of Customer
}
}
int main()
{
system("COLOR FC");
//Function to change color of background and Text.
hotel h;
system("cls");
cout<<"\n\t\t\t----------------------------";
cout<<"\n\t\t\t- HOTEL MANAGEMENT PROJECT -";
cout<<"\n\t\t\t----------------------------";
cout<<"\n\n\n\n\t\tMade By:";
cout<<"1.Haider Ali";
cout<<"\n\t\t\t2.Ganeshyam Nair";
cout<<"\n\t\t\t3.Mohammed Irshaad";
cout<<"\n\n\t\tSubmitted To:";
cout<<"Mrs. Anita ";
cout<<"\n\n\n\t\t\Press any key to continue";
getch();
h.main_menu();
return 0;
}

BOOKS:
------------------------------------------------------------------------------------

Computer Science with C++ by Sumitha Arora.(Class 12)


------------------------------------------------------------------------------------

INTERNET:
------------------------------------------------------------------------------------

www.tutorialspoint.com
www.stackoverflow.com
www.codeblocks.com
------------------------------------------------------------------------------------

You might also like