Sunteți pe pagina 1din 20

Computer Science

Investigatory Project
Hotel Management
AISSCE 2015-16
- Yash G.Desai
- XII-A
- Kendriya Vidyalaya INS
Hamla
- Roll No. :

Certificate
This is to certify that YASH G.DESAI of Class XII-A has prepared the
investigatory project entitled
HOTEL MANAGEMENT. The project is the result of his efforts &
endeavors. This is accepted as final project for the subject Computer
Science for Class XII.
Internal Examiner
Examiner

Principal

External

Contents

Acknowledgement
Abstract
Class and data members
Source code
Output
Bibliography

Acknowledgement
I place my sincere thanks to my Computer Science
teacher
Mr. Sumit Sahu for his guidance and advices to complete
my
work successfully. He provided me the software for
programs
and helped me in rectification of errors.
I would also like to thank my parents for their
encouragement
and support in my humble venture.

Abstract
The project is aimed to create a program in C++ for
carrying out effective management of records of
customers for efficient hotel management using concept
of data file handling.
The program allows the user to book rooms, input, modify
and delete customer details, display records and generate
bill based upon type of room and no. of days occupied .

Class & Data


Members
Class : hotel
Data
TYPE
Members

Purpose

room_no

signed int

name[30]

char

For booking and identification


of any customer.
For storing name of any
customer.
For storing address of any
customer.
For storing phone number of
any customer.

address[50] char
phone[20]

char

Source
Code

/********************************
* HEADER FILES USED IN THE
PROJECT
*********************************/
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
#include<dos.h>
#include<stdio.h>
#include<iomanip.h>
#include<string.h>

/********************************
* CLASS USED IN THE PROJECT *
*********************************/
class hotel
{signed int room_no;
char name[30];
char address[50];
char phone[20];
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 bill();
//to generate bill
}; hotel h;
/*******************************
* FUNCTION TO DISPLAY THE MAIN MENU *
*******************************/
void hotel::main_menu()
{
int choice;
while(choice!=6)
{
clrscr();

cout<<"\n\n";
cout<<" \t
----------------------------------------------------------- \n";
cout<<" \t|| *
*
* * * * ** * *
* * * * || \n";
cout<<" \t|| * *
*
* *
** * *
* *
|| \n";
cout<<" \t|| * * *
* *
***
* * * *
* ***
|| \n";
cout<<" \t|| *
*
**
*
* ** *
* *
|| \n";
cout<<" \t||*
*
*
* * * * **
**** * * * || \n";
cout<<" \t
----------------------------------------------------------- ";
cout<<"\n\n";
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.Bill";
cout<<"\n\t\t\t6.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: bill();
break;
case 6: break;
default: cout<<"\n\n\t\t\tWrong choice.....!!!";
cout<<"\n\t\t\tPress any key to continue....!!";
getch();
}}}
/************************
* FUNCTION TO BOOK A ROOM *
*************************/
void hotel::add()
{clrscr();
int r, flag=0;
ofstream fout("Record1.dat",ios::app);
cout<<"\n Enter Customer Details";
cout<<"\n ----------------------";
cout<<"\n\n Room no: ";
cin>>r;
flag=check(r);
if(flag==1)
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();
}
/************************
* FUNTION TO CHECK ROOM STATUS *
************************/
int hotel::check(int r)
{
int flag=0;
ifstream fin("Record1.dat",ios::in);
while(!fin.eof())
{
fin.read((char*)this,sizeof(hotel));
if(room_no==r)
{flag=1;
break;
}}
fin.close();
return flag;
}
/*****************************
* FUNCTION TO DISPLAY CUSTOMER
RECORD
******************************/

void hotel::display()
{clrscr();
ifstream fin("Record1.dat",ios::in);
int r,flag=0;
cout<<"\n Enter room no: ";
cin>>r;
while(!fin.eof())
{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 Sorry Room no. not found or
vacant....!!";
cout<<"\n\n Press any key to continue....!!";
getch();
fin.close();
}

/***********************
* FUNCTION TO DISPLAY ALLOTED
ROOM
*
***********************/
void hotel::rooms()
{clrscr();
ifstream fin("Record1.dat",ios::in);
cout<<"\n\t\t\t List Of Rooms Allotted";
cout<<"\n\t\t\t ----------------------";
cout<<"\n\n Room No. Name\t\t
Address\t\t\t Phone No.\n";
while(fin.read((char*)this,sizeof(hotel)))
{cout<<"\n\n "<<"
"<<room_no<<"
"<<name;
cout<<"\t"<<address<<"\t"<<phone;}
cout<<"\n\n\n\t\t\tPress any key to
continue.....!!";
fin.close();
}
getch();
/**************************
* FUNCTION TO EDIT CUSTOMER RECORD
************************/
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)
{
case2:
1:delete_rec(r);
modify(r); break;
case
break;
default: cout<<"\n Wrong Choice.....!!";
}
cout<<"\n Press any key to
continue....!!!";getch();
}/****************************
* FUNTION TO MODIFY RECORD
***************************/
void hotel::modify(int r)
{
long pos,flag=0;
*

fstream file("Record1.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();
}
/****************************
* FUNTION TO DELETE RECORD
*
****************************/
void hotel::delete_rec(int r)
{
int flag=0;
char ch;
ifstream fin("Record1.dat",ios::in);
ofstream fout("temp.dat",ios::out);
while(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

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("Record1.dat");
rename("temp.dat","Record1.dat"); }}
/*************************
* FUNTION TO GENERATE BILL *
**************************/
void hotel::bill()
{int days, r, flag;
float price;
char fullname[30];
start:
clrscr();
cout<<"BILL GENERATION MENU";
cout<<"\n\nRoom no. :";
cin>>r;
flag=check(r);
if(flag==1)
{cout<<"\nEnter no. days :";
cin>>days;
cout<<"\nChoose type of room from the
following:";
cout<<"\n\n1.Non AC Ordinary \n2.AC Ordinary

int opt;
cin>>opt;
ifstream fi("Record1.dat",ios::in|ios::binary);
while(!fi.eof())
{out<<"\nGenerating bill...";
sleep(2);
if(room_no==r)
{int pos=-1*sizeof(h);
fi.seekg(pos,ios::cur);
fi.read((char*)this,sizeof(h));
strcpy(fullname,name);}
break; }
price= opt * 500 * days;
cout<<"\n**********************";
cout<<"\n*
HOTEL AVENUE
*";
cout<<"\n*
Charkop Sec. No.6,
Kandivali(W), *";
cout<<"\n\n
*
INVOICE
*";
cout<<"\n
*
*";
cout<<"\n
Customer Name :
"<<fullname;
cout<<"\n
Days : "<<days;
cout<<"\n
Amount
be paid for
:
cout<<"Room
not found
to be to
occupied
"<<price;
biling";
cout<<"\n**********************";
cout<<"\n\nEnter
1. To go back to Main Menu";
getch();
}
cout<<"
2. To back to billing menu";
else
int ch;
cin>>ch;
if(ch==1)

/**************************
THE MAIN FUNTION OF THE PROGRAM
****************************/
void main()
{
textmode(C80);
textbackground(WHITE);
textcolor(RED);
clrscr();
cout<<"\n\t\t\t****************************
";
cout<<"\n\t\t\t* HOTEL MANAGEMENT
PROJECT
*";cout<<"\n\t\t\t*************************
***;
sleep(2);
cout<<"\n\n\n\n\t\tPrepared By :";
sleep(0.5);
cout<<"\t Divesh Shukla";
sleep(1);
cout<<"\n\n\t\tStd. :";
cout<<"\n\n\t\tSchool
Name :";
sleep(0.5);
sleep(0.5);cout<<"\t
cout<<"\t
XII-A"; KV INS HAMLA";
sleep(1);
sleep(1);
cout<<"\n\n\t\tSubmitted To :";
sleep(0.5);
cout<<"\t Mr. SUMIT SAHU";
sleep(1);
cout<<"\n\n\n\t\t\t\t\tPress any key to
continue....!!";
getch(); h.main_menu();}

Outputs

Main menu

Adding New
Customer
Record

Viewing
Customer Details

Edit Menu:
Modifying and deleting
records

Display of all
records

Billing

Bibliography

www.cppforschool.com
mycbseguide.com
www.google.co.in
stackoverflow.com

S-ar putea să vă placă și