Professional Documents
Culture Documents
HOTEL MANAGEMENT
P Lakshmi
XII B
Acknowledgment
1
Table of Contents
2
Introduction
This application was created using C++. The program enables one to perform
multiple data-based operations.
The facilities provided in this application includes creation, deletion and
searching of existing records. Users also have the options to display records or
exit from the program.
Use of binary files helps in hiding of data and reduces chances of data loss
3
About C++
4
File Design
Header Files
S. No. Header File Purpose
Class
class sports
S. Members Data Size Description
No. Type
1. room_no int 2 Number of room allotted
The program stores data in the form of binary files. This facilitates
data hiding and also reduces loss of information
Source Code
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
#include<stdio.h>
class hotel
{
int room_no;
char name[30];
char address[50];
char phone[10];
public:
void main_menu();
void add();
void display();
void rooms();
void edit();
int check(int);
void modify(int);
void delete_rec(int);
};
void hotel::main_menu()
{
int choice;
while(choice!=5)
{
clrscr();
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: add();
break;
case 2: display();
break;
case 3: rooms();
break;
case 4: edit();
break;
case 5: break;
default:
{
cout<<"\n\n\t\t\tError : Invalid choice";
cout<<"\n\t\t\tPress any key to continue";
getch();
}
}
}
}
void hotel::add()
{
clrscr();
int r, flag;
ofstream fout("Record.dat", ios::app);
cout<<"\n Enter Customer Details";
cout<<"\n\n Room no: ";
cin>>r;
flag=check(r);
if(flag)
cout<<"\n Sorry, the room is already booked";
else
{
room_no=r;
cout<<" Name: ";
gets(name);
cout<<" Address: ";
gets(address);
cout<<" Phone No: ";
gets(phone);
fout.write((char*)this, sizeof(hotel));
cout<<"\n Room Booked";
}
void hotel::display()
{
clrscr();
ifstream fin("Record.dat", ios::in);
int r, flag;
cout<<"\n Enter room no: ";
cin>>r;
while(fin.read((char*)this, sizeof(hotel)))
{
if(room_no==r)
{
clrscr();
cout<<"\n Customer Details";
cout<<"\n ________________________";
cout<<"\n\n Room no: "<<room_no;
cout<<"\n Name: "<<name;
cout<<"\n Address: "<<address;
cout<<"\n Phone no: "<<phone;
flag=1;
break;
}
}
if(flag==0)
cout<<"\n Error : Room not found or Room vacant";
void hotel::rooms()
{
clrscr();
ifstream fin("Record.dat", ios::in);
cout<<"\n\t\t\tList Of Rooms Allotted";
cout<<"\n\t\t\t_______________________";
cout<<"\n\n Room No.\tName\t\tAddress\t\tPhone No.\n";
while(fin.read((char*)this, sizeof(hotel)))
{
cout<<"\n\n "<<room_no<<"\t\t"<<name;
cout<<"\t\t"<<address<<"\t\t"<<phone;
}
void hotel::edit()
{
clrscr();
int choice, r;
switch(choice)
{
case 1: modify(r);
break;
case 2: delete_rec(r);
break;
default: cout<<"\n Error :Invalid choice";
}
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.read((char*)this, sizeof(hotel)))
{
pos = file.tellg();
if(room_no==r)
{
cout<<"\n Enter New Details";
cout<<"\n Name: ";
gets(name);
cout<<" Address: ";
gets(address);
cout<<" Phone no: ";
gets(phone);
file.seekg(pos);
file.write((char*)this,sizeof(hotel));
cout<<"\n Record modified";
flag=1;
break;
}
}
if(flag==0)
cout<<"\nError : Room not found or Room 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 Address: "<<address;
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 Error : Room not found or Room vacant";
else
{
remove("Record.dat");
rename("temp.dat", "Record.dat");
}
}
void main()
{
hotel h;
clrscr();
cout<<"\n\t\t\t HOTEL MANAGEMENT PROJECT ";
cout<<"\n\t\t\t______________________________";
cout<<"\n\n\n\n\t\tMade By : ";
cout<<"P Lakshmi and Geethu Paulson";
cout<<"\n\n\n\n\n\t\t\t\tPress any key to continue";
getch();
h.main_menu();
}
Screenshots
Introduction Screen
Main Menu
Booking in a Customer
Displaying Details of a Customer
Displaying all Records
With this project, I have applied the 12th standard concepts of C++
programming that I have studied. I have also dealt with different
programming errors that have occurred during code creation. Creating
this project has strengthened my understanding of this application.
I believe this program shall be useful to hotel staff in managing their
business.
Bibliography
https://www.google.co.in/
https://www.wikipedia.org/