You are on page 1of 29

COMPUTER PROJECT

HOTEL MANAGEMENT

P Lakshmi
XII B
Acknowledgment

I would like to express my gratitude to our Principal, Fr. John


Mannarathara who gave me the opportunity to do this project on the
topic “Hotel Management System”. I would also like to thank our
teacher, Ms. Beena Kattakayam, for providing us valuable input as well
as support. Secondly, I would like to thank my parents for their
concern. Last, but not the least, we thank our classmates who extended
a helping hand while working on this project.

1
Table of Contents

S. No. Contents Page No.


1. Introduction 3
2. About C++ 4
3. File Design 5
4. Synopsis 6
5. Source Code 7
6. Screenshots 21
7. Conclusion 26
8. Bibliography 27

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++

C++ is a general-purpose programming language. It has imperative, object-


oriented and generic programming features, while also providing facilities
for low-level memory manipulation.
In 1979, Bjarne Stroustrup, a Danish scientist, had worked on "C with Classes",
which later developed into C++.The name “C++” is credited to Rick Mascitti.
The name comes from C's ++ operator and a convention of using "+" to indicate
an enhanced computer program.
C++ supports function, class, alias and variable templates.
Important Features of C++
 Simplicity  Platform  Compiler based
 Portability dependent  Syntax based
 Powerful  Object oriented language
 Case sensitive  Use of Pointers

4
File Design
Header Files
S. No. Header File Purpose

1. iostream.h cin, cout stream objects

2. conio.h clrscr() and getch() functions

3. fstream.h File handling purposes

4. stdio.h gets(), remove() and rename functions

Class

class sports
S. Members Data Size Description
No. Type
1. room_no int 2 Number of room allotted

2. name char 30 Name of customer

3. address char 50 Residential address of


customer
4. phone char 10 Phone number of customer
Synopsis
This project is designed for a hotel. The programming language used
is C++. The title of the project is “Hotel Management”. Using this
program, staff concerned can book in customers without hassle, and
can keep a record of the details of the rooms allotted. The program
allows modification as well as deletion of records.

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";
}

cout<<"\n Press any key to continue";


getch();
fout.close();
}

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";

cout<<"\n\n Press any key to continue";


getch();
fin.close();
}

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

cout<<"\n\n\n\t\t\tPress any key to continue";


getch();
fin.close();
}

void hotel::edit()
{
clrscr();
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;
clrscr();
cout<<"\n Enter room no: ";
cin>>r;

switch(choice)
{
case 1: modify(r);
break;
case 2: delete_rec(r);
break;
default: cout<<"\n Error :Invalid 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.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

Modification of Details of a Customer


Deletion of a Customer Record
Conclusion

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/

You might also like