Anda di halaman 1dari 32

qwertyuiopasdfghjklzxcvbnmqw

ertyuiopasdfghjklzxcvbnmqwert
yuiopasdfghjklzxcvbnmqwertyui
COMPUTER PROJECT
opasdfghjklzxcvbnmqwertyuiopa
sdfghjklzxcvbnmqwertyuiopasdf
Hotel Management and
Reservation System
ghjklzxcvbnmqwertyuiopasdfghj
Danish Ahmad Khan
klzxcvbnmqwertyuiopasdfghjklz
xcvbnmqwertyuiopasdfghjklzxcv
bnmqwertyuiopasdfghjklzxcvbn
mqwertyuiopasdfjklzxcvbnmqwe
rtyuiopasdfghjklzxcvbnmqwerty
uiopasdfghjklzxcvbnmqwertyuio
pasdfghjklzxmwertyuiopasdfghj
SUBMITED TO:
klzxcvbnmqwertyuiopasdfghjklz
COMPUTER DEPARTMENT
xcvbnmqwertyuiopasdfghjklzxcv
SUMMER FIELDS SCHOOL

ACKNOWLEDGEMENT
It gives me great pleasure in expressing my
sincere thanks and deep sense of gratitude to
respected c++ teacher Mr.Satyendra Kumar
for his valuable guidance, support and
encouragement for the fulfilment of this
project.

Danish Ahmad Khan

CERTIFICATE
This is to certify that Danish Ahmad Khan,
student of class XII-C, Summer Fields School
Kailash Colony, has completed the project
titled Hotel Management and Reservation
System during the academic year 2014 2015 for C.B.S.E higher secondary
examinations.

Mr Satyendra Kumar
(Subject teacher)

CODE

#include<fstream>
#include<iomanip>
#include<string.h>
#include<stdio.h>
#include<conio.h>
#include<process.h>
#include<stdlib.h>
int tidno=1000,tnormal=100,tsuite=20,tpenthouse=1;
int check(int ch)
{
if(ch==1)
{
if(tnormal==0)
return 0;
else
{
tnormal--;
return 1;
}
}
if(ch==2)
{
if(tsuite==0)
return 0;
else
{
tsuite--;
return 1;
}
}if(ch==3)
{
if(tpenthouse==0)
return 0;
else
{
tpenthouse--;
return 1;
}
}
}
class reservation
{
int idno;
char name[20];
int date;

int year;
char month[10];
int no_of_days;
char room[10];
int buffet;
int tour;
float total;
public:
reservation()
{
total=0;
tour=0;
buffet=0;
}
void assignroom(int ch)
{
if(ch==1)
strcpy(room,"Normal");
else if(ch==2)
strcpy(room,"Suite");
else
strcpy(room,"Penthouse");
}
void calculate()
{
total=0;
if(strcmpi(room,"Normal")==0)
total+=no_of_days*2000;
else if(strcmpi(room,"Suite")==0)
total+=no_of_days*5000;
else
total+=no_of_days*10000;
if(buffet==1)
total+=no_of_days*1000;
if(tour==1)
total+=2000;
}
void reserve()
{
int ch,c=1,no_of_days1,date1,year1;
char b,t,conf,name1[20],month1[10];
cout<<"\n\nEnter Name:";
//cin.getline(name,20,'\n');

cin>>name1;
cout<<"\n\nEnter No of Days:";
cin>>no_of_days1;
do{
cout<<"\n\nEnter Type of Room:\n";
cout<<"1.Normal(Rs 2000 per night)\n2.Suite(Rs 5000 per night)\n3.Penthouse(Rs 10000 per
night)";
cout<<"\nEnter choice:";
cin>>ch;
if(!(check(ch)))
{
c=-1;
cout<<"\nThat type of room is not available...\nPlease choose another room.";
}
else
c++;
}while(c==-1);
cout<<"\n\nEnter Check in date:\n1.Date:";
cin>>date1;
cout<<"2.Month:";
cin>>month1;
cout<<"3.Year:";
cin>>year1;
cout<<"\nWould you like our Breakfast, Lunch and Dinner Service?(Rs 1000 per day)(y/n):";
cin>>b;
cout<<"\nWould you like our Special Touring Package?(Rs 2000)(y/n):";
cin>>t;
cout<<"\nConfirm?(y/n):";
cin>>conf;
if(conf=='y')
{
no_of_days=no_of_days1;
if(b=='y')
buffet++;
if(t=='y')
tour++;
strcpy(name,name1);
date=date1;
strcpy(month,month1);
year=year1;
assignroom(ch);
calculate();
cout<<"\n\nBooking confirmed!!";
idno=tidno;
tidno++;
cout<<"\nYour Identification No. is:"<<idno;
cout<<"\nYour total amount is:"<<total;
}

else
cout<<"Ticket Not Reserved";
}
void checkreserve()
{
cout<<"\n\n\n\nIdentification No.:"<<idno;
cout<<"\nName:"<<name;
cout<<"\nNo. of Days:"<<no_of_days;
cout<<"\nType of room:"<<room;
if(buffet==1)
cout<<"\nBuffet Included.";
if(tour==1)
cout<<"\nTour Included.";
cout<<"\nTotal Charges:"<<total;
}
int returnid()
{
return idno;
}
int checkname()
{
if(strcmpi(room,"Normal")==0)
return 1;
else if(strcmpi(room,"Suite")==0)
return 2;
else
return 3;
}
void upgradename()
{
char ch[20];
cout<<"\nEnter New Name:";
cin>>ch;
strcpy(name,ch);
}
void upgradedays()
{
int n;
cout<<"\nEnter No of Days:";
cin>>n;
no_of_days=n;
calculate();
cout<<"\n\nYOUR NEW TOTAL:"<<total;

}
void upgradetype(int temp=0)
{
if(strcmpi(room,"Normal")==0)
{
tnormal++;
calculate();
}
else if(strcmpi(room,"Suite")==0)
{
tsuite++;
calculate();
}
else
{
tpenthouse++;
calculate();
}
assignroom(temp);
}
float returntotal()
{
return total;
}
void upgradedoa()
{
int dd,yy;
char mm[20];
cout<<"\nEnter new date:";
cin>>dd;
cout<<"\nEnter new month:";
cin>>mm;
cout<<"\nEnter new year:";
cin>>yy;
date=dd;
year=yy;
strcpy(month,mm);
}
void upgradeb()
{
if(buffet==1)
{
cout<<"\nBuffet Service is Removed from your package.";
buffet--;
}

else
{
cout<<"\nBuffet Service is Added to your package.";
buffet++;
}
calculate();
cout<<"\n\nYOUR NEW TOTAL:"<<total;
}
void upgradet()
{
if(tour==1)
{
cout<<"\nTouring Service is removed from your package.";
tour--;
}
else
{
cout<<"\nTouring Service is added to your package.";
tour++;
}
calculate();
cout<<"\n\nYOUR NEW TOTAL:"<<total;
}
};
void create()
{
ofstream f("TM Hotels.dat",ios::binary);
}
int display()
{
clrscr();
int id;
cout<<"\t\t\tCHECK RESERVATION";
cout<<"\n\n\nEnter Identification No:";
cin>>id;
ifstream f("TM Hotels.dat",ios::binary);
reservation r;
while(f.read((char *)&r , sizeof(r)))
{
if(r.returnid()==id)
r.checkreserve();
}
f.close();
char c2;
cout<<"\n\nGO BACK TO MENU?(y/n):";

cin>>c2;
if(c2=='n')
exit(1);
else
return 1;
}
int cancellation()
{
clrscr();
int id;
cout<<"\t\t\tCANCEL RESERVATION";
cout<<"\n\n\nEnter Identification No:";
cin>>id;
ifstream f("TM Hotels.dat",ios::binary);
ofstream g("temp.dat",ios::binary);
reservation r;
int del=-1;
while(f.read((char *)&r , sizeof(r)))
{
if(id!=r.returnid())
{
g.write((char *)&r , sizeof(r));
}
else
{
del=1;
r.checkreserve();
r.upgradetype();
}
}
if(del==-1)
cout<<"\nError, Id no not found!!";
else
cout<<"\nReservation successful canceled";
f.close();
g.close();
remove("TM Hotels.dat");
rename("temp.dat","TM Hotels.dat");
char c2;
cout<<"\n\nGO BACK TO MENU?(y/n):";
cin>>c2;
if(c2=='n')
exit(1);
else
return 1;
}

int add()
{
clrscr();
cout<<"\t\t\tNEW RESERVATION\n\n\n";
ofstream f("TM Hotels.dat",ios::binary|ios::app);
reservation r;
r.reserve();
f.write((char *)&r , sizeof(r));
f.close();
char c2;
cout<<"\n\nGO BACK TO MENU?(y/n):";
cin>>c2;
if(c2=='n')
exit(1);
else
return 1;
}
int upgrade()
{
clrscr();
int bno;
cout<<"\t\t\tCHANGE RESERVATION";
cout<<"\n\n\nEnter Identification No:";
cin>>bno;
fstream f("TM Hotels.dat",ios::binary|ios::in|ios::out);
reservation r;
char c;
int ch,x=0;
f.read((char *)&r , sizeof(r));
do
{
if(r.returnid()==bno)
{
x++;
r.checkreserve();
long int n;
cout<<"\n\nWhat would you like to change?\n1.Name on Reservation\n2.No of Days\n3.Type of
Room";
cout<<"\n4.Date of Arrival\n5.Buffet Service\n6.Touring Service\nEnter Choice:";
cin>>ch;
int flag=1,temp3;
switch(ch)
{
case 1:
n=f.tellp()-sizeof(r);
f.seekp(n);

r.upgradename();
f.write((char *)&r , sizeof(r));
break;
case 2:
n=f.tellp()-sizeof(r);
f.seekp(n);
r.upgradedays();
f.write((char *)&r , sizeof(r));
break;
case 3:
n=f.tellp()-sizeof(r);
f.seekp(n);
do
{
cout<<"\n\nEnter type of room\n1.Normal(Rs 2000 per night)";
cout<<"\n2.Suite(Rs 5000 per night)";
cout<<"\n3.Penthouse(Rs 10000 per night)\nEnter Choice:";
cin>>temp3;
if(!(check(temp3)))
cout<<"\nThat type of room is not available...\nPlease choose another room.";
else
flag=-1;
}while(flag==1);
r.upgradetype(temp3);
cout<<"\n\nYOUR NEW TOTAL:"<<r.returntotal();
f.write((char *)&r , sizeof(r));
break;
case 4:
n=f.tellp()-sizeof(r);
f.seekp(n);
r.upgradedoa();
f.write((char *)&r , sizeof(r));
break;
case 5:
n=f.tellp()-sizeof(r);
f.seekp(n);
r.upgradeb();
f.write((char *)&r , sizeof(r));
break;
case 6:
n=f.tellp()-sizeof(r);
f.seekp(n);
r.upgradet();
f.write((char *)&r , sizeof(r));
break;
}
}
f.read((char *)&r , sizeof(r));

}while(f);
f.close();
if(x==0)
cout<<"\nERROR RESERVATION NOT FOUND!!";
char c2;
cout<<"\n\nGO BACK TO MENU?(y/n):";
cin>>c2;
if(c2=='n')
exit(1);
else
return 1;
}
int employee()
{
clrscr();
int id;
cout<<"\t\t\tEMPLYEE AREA";
int ch=0;
char c,pass[10];
cout<<"\n\n\nEnter your special employee code:";
cin>>pass;
if(strcmpi(pass,"123ab")==0)
{
do
{
clrscr();
cout<<"\t\t\tEMPLOYEE AREA";
cout<<"\n\n\n\t\t\t MENU\n\n1.Check Number of Rooms Available";
cout<<"\n\n2.Display Details of Guests";
cout<<"\n\nEnter Choice:";
cin >>ch;
switch(ch)
{
case 1:
clrscr();
cout<<"\t\t\tEMPLOYEE AREA";
cout<<"\n\n\n\nNormal Rooms\n\nBooked:"<<(100-tnormal)<<"\tAvailable:"<<tnormal;
cout<<"\n\n\nSuites\n\nBooked:"<<(20-tsuite)<<"\tAvailable:"<<tsuite;
cout<<"\n\n\nPenthouse\n\nBooked:"<<(1-tpenthouse)<<"\tAvailable:"<<tpenthouse;
break;
case 2:
int temp;
clrscr();
cout<<"\t\t\tEMPLOYEE AREA";
ifstream f("TM Hotels.dat" , ios::binary);
cout<<"\n\n\n\n MENU\n1.Display Guests in Normal Rooms";
cout<<"\n2.Display Guests in Suites";

cout<<"\n3.Display Guests in Penthouse";


cout<<"\n4.Display all Guests\n\nEnter choice:";
cin>>temp;
clrscr();
switch(temp)
{
case 1:
if(tnormal==100)
{
cout<<"\t\t\tEMPLOYEE AREA";
cout<<"\n\n\nNo guest is booked for normal room.";
}
else
{
cout<<"\t\t\tEMPLOYEE AREA\n\n\n";
reservation r;
ifstream f("TM Hotels.dat" , ios::binary);
while(f.read((char *)&r , sizeof(r)))
{
if(r.checkname()==1)
r.checkreserve();
}
f.close();
}
break;
case 2:
if(tsuite==20)
{
cout<<"\t\t\tEMPLOYEE AREA";
cout<<"\n\n\nNo guest is booked for a suite.";
}
else
{
reservation r;
cout<<"\t\t\tEMPLOYEE AREA\n\n\n";
ifstream f("TM Hotels.dat" , ios::binary);
while(f.read((char *)&r , sizeof(r)))
{
if(r.checkname()==2)
r.checkreserve();
}
f.close();
}
break;
case 3:
if(tpenthouse==1)
{
cout<<"\t\t\tEMPLOYEE AREA\n\n";

cout<<"\nNo guest is booked for the penthouse.";


}
else
{
cout<<"\t\t\tEMPLOYEE AREA\n\n\n";
reservation r;
ifstream f("TM Hotels.dat" , ios::binary);
while(f.read((char *)&r , sizeof(r)))
{
if(r.checkname()==3)
r.checkreserve();
}
f.close();
}
break;
case 4:
reservation r;
cout<<"\t\t\tEMPLOYEE AREA\n\n\n";
ifstream f("TM Hotels.dat" , ios::binary);
f.read((char *)&r , sizeof(r));
do
{
r.checkreserve();
f.read((char *)&r , sizeof(r));
} while(f);
f.close();
break;
}
}
cout<<"\n\nCheck another delatil?(y/n):";
cin>>c;
}while(c=='y');
}
else
cout<<"Invalid Password";
char c2;
cout<<"\n\nGO BACK TO MENU?(y/n):";
cin>>c2;
if(c2=='n')
exit(1);
else
return 1;
}
void pattern()
{
for (int i=1;i<=5;i++)
{

cout<<"\n\t\t\t\t";
for(int j=5-i;j>=1;j--)
cout<<" ";
for(int k=1;k<=i;k++)
cout<<"*";
for(int l=i-1;l>0;l--)
cout<<"*";
}
for(int m=4;m>=1;m--)
{
cout<<"\n\t\t\t\t";
for(int n=5-m;n>=1;n--)
cout<<" ";
for(int o=m-1;o>=0;o--)
cout<<"*";
for(int p=m-2;p>=0;p--)
cout<<"*";
}
}
void main()
{
int ch;
create();
char c;
do{
clrscr();
pattern();
cout << "\n\n\t\t\t WELCOME TO TM HOTELS !!" << endl;
pattern();
cout<<"\n\n\n\n\n\t\t\t\t MENU";
cout<<"\n1.New Reservation \n2.Check Reservation \n3.Cancel Reservation";
cout<<"\n4.Change Reservation\n5.Employee Portal";
cout<<"\n6.Exit\nEnter Choice:";
cin>>ch;
switch(ch)
{
case 1:
c=add();
break;
case 2:
c=display();
break;
case 3:
c=cancellation();
break;
case 4:

c=upgrade();
break;
case 5:
c=employee();
break;
case 6:
cout<<"Thank You!";
exit(1);
}
}while(c==1);
}

OUTPUT

Opening screen; Menu.

Screen for entering details of new reservation;


Input function.

Screen for making new reservation(2); input


function. User tries to book a penthouse which
was not available.

Cancelling a reservation; deleting a record.

Changing a reservation; modifying a record.

Changing details of a reservation; modifying a


record.

Screen to log/view into employees data.


(password-123ab)

Screen displaying employees menu.

Screen showing the number of rooms


available.(accessible to employees only)

Employees menu.

Checking number of guests in every type of


room. (Option can be accessed by an employee
only)

Checking details of all guests. (Accessible to


employee only)

Bibliography

Computer science with SumitaArora


www.cplusplus.com

Anda mungkin juga menyukai