Вы находитесь на странице: 1из 15

CONTENTS

1. Acknowledgement
2. Introduction
3. System Requirements
4. Program Description
5. Source Code with Output
6. Bibliography
ACKNOWLEDGEMENT

In performing our assignment, we had to take the help and


guideline of some respected persons, who deserve our
greatest gratitude. The completion of this assignment gives
us much Pleasure. We would like to show our
gratitude Mrs. Anindita Ghosh, Computer Science
Instructor, Salt Lake Shiksha Niketan for giving us a
good guideline for assignment throughout numerous
consultations. We would also like to expand our deepest
gratitude to all those who have directly and indirectly
guided us in writing this assignment.
INTRODUCTION

With the development of social service industries, using software to manage the hotel business
requirements are gradually warming, conditional hotel before going to the relevant hotel management
through, resolved depends on the original manual records management, inefficient, error-prone flaws,
the hotel industry itself to provide the quality of service and the ability to have it higher requirements,
hotel information management system is therefore increasingly attention. Hotel information
management system to achieve the hotel rooms management, customer information management,
customer management add , modify customer management, customer management function.so the
whole hotel information management system is divided into two parts, room management and
customer management, Including background and foreground database management and maintenance
operations, Admin database system can guarantee the normal operation of the various functions.
Foreground operation can provide to hotel customers as convenient and efficient service.

This system is more detailed discussion of the major hotel management system functional requirements.
For the main function discussed its technology, Including system design database, Each application
design and data exchange and interface design, This system can be applied to the current hotel
management ,Most hotel management to meet job requirements, In order to improve the efficiency of
hotel management role, Become a successful example of management information.

In this system we will make extensive use of files system in C.. We will have a login id system initially. In
this system we will be having separate fiinctions for

• Getting the information

• Getting customer information who are lodged in

• Allocating a room to the customer

• Preparing a billing function for the customer according to his room no.

In this program we will be using the many features of C++ programming language. We will be using
various functions, classes and arrays to our pupose of storing and displaying the information.
SYSTEM REQUIREMENTS

Software
1. Turbo C++.
2. OS: Windows XP or higher.

Hardware
1. Monitor
2. Keyboard
3. Mouse
4. A working CPU

Program code description


This program has been made by the use of various important features of C++ such
as Data file handling (Binary files), concepts of Object-Oriented Programming such
as Classes and objects, this pointer and many more.

The complete program is menu driven. When the main menu opens then the user
can enter his/her choice. The program continues according to the user choice by
calling the required member functions of the class ”Hotel”. Whenever a new room
is allotted to the customer, a member function is called and then, all the details of
the customer such as “Name, Phone number, Address, Room Number “are stored
and encapsulated in a single object. Now this object is stored in a binary file
“Record.dat”. Thus, every time a new room is allotted, a new object is written into
the file “Record.dat”. During the whole process of writing object to the file, the
current object is pointed by the “this” pointer, which is very useful in this case,
because the necessity of declaring multiple objects every time is eliminated like
this.

Now whenever there is a need to show details of a customer, then the file
“Record.dat” is read by using inbuilt function “read ()”. The required object is
searched inside the file and then the details of the customer are shown.

In a very similar way the records of a customer can also be deleted. For that the
file is read, then the required object with the room to be deallocated is searched,
then the delete operation is performed through the desired member function.

This was the main concept and logic behind the working of the program.

SOURCE CODE

#include<iostream.h>
#include<conio.h>
#include<fstream.h>
#include<stdio.h>
#include<dos.h>

class hotel
{
int room_no;
char name[30];
char address[50];
char phone[10];

public:
void main_menu(); //to dispay the main menu
void add(); //to book a room
void display(); //to display the customer record
void rooms(); //to display alloted rooms
void edit(); //to edit the customer record
int check(int); //to check room status
void modify(int); //to modify the record
void delete_rec(int); //to delete the record
};

void hotel::main_menu()
{
int choice;

while(choice!=5)
{
clrscr();
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: add();
break;
case 2: display();
break;
case 3: 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::add()
{
clrscr();
int r,flag;
ofstream fout("Record.dat",ios::app);

cout<<"\n Enter Customer Detalis";


cout<<"\n **********************";
cout<<"\n\n Room no: ";
cin>>r;
flag=check(r);

if(flag)
cout<<"\n Sorry..!!!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 is 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.eof())
{
fin.read((char*)this,sizeof(hotel));
if(room_no==r)
{
clrscr();
cout<<"\n Cusromer 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 Sorry Room no. not found or 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.eof())
{
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 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: ";
gets(name);
cout<<" Address: ";
gets(address);
cout<<" Phone no: ";
gets(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 Address: "<<address;
cout<<"\n Pone 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");
rename("temp.dat","Record.dat");
}
}

void main()
{
hotel h;

clrscr();
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<<" Sreyan, Divas, Polok, Kanishk";

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


getch();
h.main_menu();
}

Bibliography

The following resources were of great help to us in


making this project.
Computer Science with C++ by SUMITA ARORA

www.cppforschool.com
www.icbse.com
www.mycbseguide.com
www.google.com

Вам также может понравиться