Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 40

SUNRISE ENGLISH PRIVATE SCHOOL

ABUDHABI -UAE

HOTEL MANAGEMENT SYSTEM

NAME : DON IGNATIUS


CLASS : XII-A
EXAM NO :
SUBJECT: COMPUTER SCIENCE
YEAR : 2015-16

STUDENT PARTICULARS
Name

: Don Ignatius

Class

: XII - A

Year: 2015-16
Exam No :
School: Sunrise English PrivateSchool
Project: Hotel Management System
Teacher: Mrs. K. Deepa

ACKNOWLEDGEMENT
I would like to express my gratitude to my teacher Mrs. K.
Deepa, as well as our principal Dr. Thakur Mulchandani who
gave me an opportunity to do this wonderful project . Being a
part of this project showcasing and expanding my knowledge on
the subject . I was also able to create an application which can
be used in reality as well .

I would also like to thank my partner Mohammad Zubin


Siddiqui without whom this project wouldnt have been a
success .

I would also like to thank my parents from the core of my heart


for providing me with the required resources for the
accomplishment of this project.

INDEX
S.no.

Title

Page
No.

1.

Aim

2.

Program Definition

3.

Algorithm

4.

Program

10

5.

Sample Output

33

6.

Conclusion

38

7.

Bibliography

39

AIM
The basic aim of this project are as follows :
To make a program by using the C++ compiler on the
topic Hotel Management System .
To understand the day to day usage of programming.
To study the various concepts of C++.
4

To analyze the methodology of program writing.


To understand the use of Algorithm.
To get the correct output.

PROGRAM DEFINITION
The following program is based on a frequently used application
Hotel Management System . In this program, a user can select
an option and to his work .the options are booking a room,
checking in, editing the profile of the user, using the gym and
swimming pool and availing the wifi services and checking out .
First, the user has to book a room . While booking , he will need
to enter his personal informations and select the type of room he
5

need . A room number is provided to him . Second, he can


check-in . While checking in, the user has to enter the room
number provided to him and his name . Third, the user can
modify his details . The user can then avail the services of
Swimming pool and Gym . A user can also use the wifi facilities
provided by the Hotel . Finally, he can check out . While
checking out, his personal details are deleted and his total bill is
printed .

ALGORITHM
Start
Declare a class Hotel with data members in introom_no, char
name[50], char address[50], long telno, char roomtype[50] and float
rent .
In the public section, define a function getdata().
Read the details of the user.
Define another function showdata().
Display the details of the customer.
Declare functions booking(), checkin(), checkout(), gym() and
swimming() and wifi() in public section.
6

In the public section, define another functions retroom() of return


type int, retname() of return type char, retaddress() of return type
char and rettel() of return type long returning the room number,
name, address, telephone number to the calling point .
Declare Hotel hp
Define a function booking() with the return type void
Open a file in ios::out mode
Using object hp, call the function getdata().
Write the details of the customer into the file
Close the file
Define the function checkin() with the return type void
Open a file in ios::in mode
Clear the screen
Enter the room number and check into the room
Declare a function edit() with the return type void
Open a file in ios::in|ios::out mode
Open a temporary file in ios::in|ios::out mode
Enter the room number and modify the details of the user .
Print the new details of the user
Declare a function display()with the return type void
Display() has an argument room_no of type int
Clear the screen
Open the file in ios::in mode
Using the function showdata(), display the details of the user
Declare a function delete() with the return type void
Delete() has an argument room_no of type int
Open a file in ios::in mode
Open a temporary file in ios::out mode
Delete the record of the user
Declare a function checkout() of return type void
7

Open a file in ios::in mode


Enter your room number and check out
Define the function gym() of return type void
Open the file in ios::in mode
Enter the room number . If room number given by the user is
correct , a message is displayed that the user can avail the facility of
gym .
Define a function swimming() of return type void
Open the file in ios::in mode
Enter the room number . If the room number enterd by the user is
correct. Then a message is displayed that the user can avail the
service of swimming pool.
Define the function wifi() with the return type void
Open a file in ios::in mode
Clear the screen
Enter the room number and name
Avail the wifi facilities . A message is printed that the user is
connected to the hotel wifi RADISSON_WIFI.
Enter void main function
Ask the user to select his options
1. Book a room
2. Check-In
3. Edit the profile of the customer
4. Gym
5. Swimming pool
6. Avail Wifi Services
7.Check-Out / Exit
Enter the choice and use the various options
Stop

PROGRAM
//computer project
//HOTEL MANAGMENT SYSTEM
//by Zubin and Don

#include<fstream.h>
#include<conio.h>
#include<process.h>
#include<stdio.h>
#include<stdlib.h>
9

#include<string.h>

class Hotel
{ private :
int room_no;
char name[50];
char address[50];
long telno;
char roomtype[50];
float rent;

public :
void getdata()
{ cout<<"\n\t\t\t ENTER YOUR NAME : ";
gets(name);
cout<<"\n\t\t\t ENTER YOUR ADDRESS : ";
gets(address);
cout<<"\n\t\t\t ENTER YOUR TELEPHONE
NUMBER : ";
cin>>telno;
}
10

void showdata()
{

cout<<"\n\t\t\t NAME : "<<name;


cout<<"\n\t\t\t ADDRESS : "<<address;
cout<<"\n\t\t\t PHONE : "<<telno;

cout<<"\n\t\t\t ROOM NUMBER :


"<<room_no;
cout<<"\n\t\t\t ROOM TYPE : "<<roomtype;
}

void booking();
void checkout();
void checkin();
void gym();
void swimming();
void wifi();

int retroom()
{return room_no;
}

11

char* retname()
{return name;
}

char* retaddress()
{return address;
}

long rettel()
{return telno;
}

};
Hotel hp;

void Hotel::booking()
{ randomize();
fstream file1;
file1.open("hotel",ios::out|ios::binary);
hp.getdata();

12

cout<<"\n";
clrscr();
REDO:
cout<<"\n\n\n";cout<<"\tROOM TYPE
"<<"\t"<<"CODE
"<<"\t"<<"CHARGES PER DAY
"<<"\n";
cout<<"\tROYAL SUITE "<<"\t"<<"1."<<"\t"<<"
AED 1500 "<<"\n";
cout<<"\tSUPER DELUXE "<<"\t"<<"2."<<"\t"<<"
AED 1200 "<<"\n";
cout<<"\tDELUXE
AED 800 "<<"\n";

"<<"\t"<<"3."<<"\t"<<"

cout<<"\tDOUBLE BED "<<"\t"<<"4."<<"\t"<<"


AED 500 "<<"\n";
cout<<"\tSINGLE BED "<<"\t"<<"5."<<"\t"<<"
AED 200 "<<"\n";

int ch;
cout<<"\n\t\t\t ENTER YOUR CHOICE : ";
cin>>ch;

switch(ch)
13

{ case 1 : strcpy(hp.roomtype,"ROYAL SUITE");


hp.rent=1500;
break;

case 2 : strcpy(hp.roomtype,"SUPER DELUXE");


hp.rent=1200;
break;

case 3 : strcpy(hp.roomtype,"DELUXE");
hp.rent=800;
break;

case 4 : strcpy(hp.roomtype,"DOUBLE BED");


hp.rent=500;
break;

case 5 : strcpy(hp.roomtype,"SINGLE BED");


hp.rent=200;
break;

14

default : cout<<"\n\t\t\t OOPS!!! YOU HAVE ENTERD


A WRONG OPTION .";
cout<<"\n\t\t\tTRY AGAIN ";
goto REDO;

hp.room_no=random(10000-5000+1);
file1.write((char*)&hp,sizeof(hp));

cout<<"\n\t\t\t YOUR BOOKING HAS BEEN


CONFIRMED ";
cout<<"\n\t\t\t YOUR ROOM NUMBER IS ";
cout<<hp.room_no;
cout<<"\n\t\t\t ENJOY YOUR STAY \n";

cout<<"\n\n\t\t\t --------------------------";
cout<<"\n\t\t\t YOUR ROOM NUMBER IS ";
cout<<hp.room_no;
cout<<"\n\t\t\t PLEASE DO NOT FORGET YOUR
ROOM NUMBER ";

15

cout<<"\n\t\t\t --------------------------";

file1.close();
cout<<"\n\n\n";

void Hotel :: checkin()


{ clrscr();
int r;
int flag=0;
char n[50];
clrscr();
fstream file2;
file2.open("hotel",ios::in|ios::binary);
file2.seekg(0);
CHECKIN:

16

cout<<"\n\t\t\t ENTER YOUR ROOM NUMBER : ";


cin>>r;

while(file2.read((char*)&hp,sizeof(hp)))
{ if(hp.retroom()==r)
{ cout<<"\n\t\t\t ENTER YOUR NAME : ";
gets(n);
if (strcmpi(hp.retname(),n)==0)
{ cout<<"\n\t\t\t YOU HAVE SUCCCESFULLY
CHECKED-IN ";
cout<<"\n\t\t\t ENJOY YOUR STAY ";
flag=1;
}
}

if(flag==0)
{ cout<<"\n\t\t\t OOPS!!! YOU HAVE ENTERD A
WRONG OPTION .";
cout<<"\n\t\t\tTRY AGAIN ";
goto CHECKIN;
}
17

cout<<"\n\n\n";
}

void edit()
{ clrscr();
int r;
int flag=0;
fstream file3,t;
file3.open("hotel",ios::in|ios::out|ios::binary);
t.open("temp",ios::in|ios::out|ios::binary);
file3.seekg(0);
EDIT:

cout<<"\n\t\t\t ENTER YOUR ROOM NUMBER : ";


cin>>r;

while(file3.read((char*)&hp,sizeof(hp)))

18

{ if(hp.retroom()==r)
{ hp.getdata();
t.write((char*)&hp,sizeof(hp));
flag=1;
}

if (flag==0)
{ cout<<"\n\t\t\t OOPS!!! YOU HAVE ENTERD A
WRONG OPTION .";
cout<<"\n\t\t\tTRY AGAIN ";
goto EDIT;
}

cout<<"\n\t\t\t YOUR DETAILS HAVE BEEN MODIFIED


";

file3.close();
t.close();

19

remove("hotel");
rename("temp","hotel");

cout<<"\n\n\n";
}

void display(int room_no)


{
fstream file4;
file4.open("hotel",ios::in|ios::binary);
file4.seekg(0);

while(file4.read((char*)&hp,sizeof(hp)))
{ if (hp.retroom()==room_no)
{ hp.showdata();
}
}

file4.close();

20

void remove(int room_no)


{ fstream file5,t;
file5.open("hotel",ios::in|ios::binary);
t.open("temp",ios::out|ios::binary);
file5.seekg(0);

while(file5.read((char*)&hp,sizeof(hp)))
{ if (hp.retroom()!=room_no)
t.write((char*)&hp,sizeof(hp));

file5.close();
t.close();

remove("hotel");
rename("temp","hotel");

21

void Hotel :: checkout()


{ clrscr();
int r,days;
char names[50];
float total;
int flag=0;

fstream file6;
file6.open("hotel",ios::in|ios::binary);
file6.seekg(0);
TRY:

cout<<"\n\t\t\t ENTER YOUR ROOM NUMBER : ";


cin>>r;

while(file6.read((char*)&hp,sizeof(hp)))
{ if(hp.retroom()==r)

22

{ cout<<"\n\t\t\t ENTER YOUR NAME : ";


gets(names);
if (strcmpi(hp.retname(),names)==0)
{ cout<<"\n\t\t\t ENTER THE NUMBER OF
DAYS YOU HAVE STAYED : ";
cin>>days;
total=days*hp.rent;
display(r);
cout<<"\n\t\t\t YOUR TOTAL BILL = AED ";
cout<<total;
cout<<"\n\t\t YOU HAVE OFFICIALLY
CHECKED OUT . THANK YOU FOR STAYING , ";
cout<<"\n\t\t\t HOPE TO SERVE YOU SOON .
";
flag=1;
}
}
}

if (flag==1)
remove(r);

23

file6.close();

cout<<"\n\n\n";
}

void Hotel :: gym()


{ clrscr();
int r;
int flag=0;

fstream file8;
file8.open("hotel",ios::in|ios::binary);
file8.seekg(0);

GYM:
cout<<"\n\t\t\t ENTER YOUR ROOM NUMBER : ";
cin>>r;

while(file8.read((char*)&hp,sizeof(hp)))

24

{ if(hp.retroom()==r)
{ cout<<"\n\t\t\t YOU CAN USE THE GYM ";
cout<<"\n\t\t\t PLEASE GO TO THE GYM AND AVAIL
THE SERVICE ";
flag=1;
}
}

if(flag==0)
{ cout<<"\n\t\t\t OOPS!!! YOU HAVE ENTERD A WRONG
OPTION .";
cout<<"\n\t\t\tTRY AGAIN ";
goto GYM;
}

file8.close();
cout<<"\n\n\n";
}

void Hotel :: swimming()


{ clrscr();
25

int r;
int flag=0;

fstream file9;
file9.open("hotel",ios::in|ios::binary);
file9.seekg(0);

SWIMMING:
cout<<"\n\t\t\t ENTER YOUR ROOM NUMBER : ";
cin>>r;

while(file9.read((char*)&hp,sizeof(hp)))
{ if(hp.retroom()==r)
{ cout<<"\n\t\t\t YOU CAN USE THE SWIMMING
POOL ";
cout<<"\n\t\t\t PLEASE GO TO THE SWIMMING
POOL AND AVAIL THE SERVICE ";
flag=1;
}
}

26

if(flag==0)
{ cout<<"\n\t\t\t OOPS!!! YOU HAVE ENTERD A WRONG
OPTION .";
cout<<"\n\t\t\tTRY AGAIN ";
goto SWIMMING;
}

file9.close();
cout<<"\n\n\n";
}

void Hotel :: wifi()


{ int r;
int flag=0;
char n[50];
clrscr();
fstream file10;
file10.open("hotel",ios::in|ios::binary);
file10.seekg(0);
WIFI:

27

cout<<"\n\t\t\t ENTER YOUR ROOM NUMBER : ";


cin>>r;

while(file10.read((char*)&hp,sizeof(hp)))
{ if(hp.retroom()==r)
{ cout<<"\n\t\t\t ENTER YOUR NAME : ";
gets(n);
if (strcmpi(hp.retname(),n)==0)
{ cout<<"\n\t\t\t YOU ARE
CONNECTED TO THE WIFI 'RADISSON_WIFI' ";

flag=1;
}
}

if(flag==0)
{ cout<<"\n\t\t\t OOPS!!! YOU HAVE ENTERD A
WRONG OPTION .";
cout<<"\n\t\t\tTRY AGAIN ";
goto WIFI;
}
28

cout<<"\n\n\n";
}

void main()
{ int choice;
char ch;
Hotel customer;
cout<<"\n\t\t\t ***************************** ";
cout<<"\n\t\t\t WELCOME TO RADDISON BLU HOTEL
";
cout<<"\n\t\t\t ***************************** ";

MENU:
cout<<"\n\t\t\t PLEASE SELECT YOUR OPTIONS ";
cout<<"\n\t\t\t 1. BOOK A ROOM ";
cout<<"\n\t\t\t 2. CHECK-IN ";
29

cout<<"\n\t\t\t 3. EDIT YOUR PROFILE ";


cout<<"\n\t\t\t 4. GYM ";
cout<<"\n\t\t\t 5. SWIMMING POOL ";
cout<<"\n\t\t\t 6. AVAIL WIFI SERVICE ";
cout<<"\n\t\t\t 7. CHECK-OUT/EXIT ";

cout<<"\n\t\t\t ENTER YOUR CHOICE : ";


cin>>choice;

switch(choice)
{ case 1 : customer.booking();
goto MENU;

case 2 : customer.checkin();
goto MENU;

case 3 : edit();
goto MENU;

30

case 4 : customer.gym();
goto MENU;

case 5 : customer.swimming();
goto MENU;

case 6 : customer.wifi();
goto MENU;

case 7 : customer.checkout();
break;

default : { cout<<"\n\t\t\t OOPS!!! YOU HAVE


ENTERD A WRONG OPTION .";
cout<<"\n\t\t\tTRY AGAIN ";
goto MENU;
}

31

cout<<"\n\t\t\t THANK YOU FOR VISITING RADISSON


BLU HOTEL . ";
cout<<"\n\t\t\t FOR MORE INFO VISIT OUR WEBSITE
www.raddisonblu.com ";
cout<<"\n\t\t\t PRESS ANY KEY TO EXIT : ";
cin>>ch;
}

SAMPLE OUTPUT

32

33

34

35

CONCLUSION
The program is found to be running successfully after correction
of all the errors , which were found when the program was being
executed .
The making of this program brought me immense pleasure .
Making this program, which has a universal appeal, was
honourable and was a very good challenge for me . The
opportunity to do such a program was very good and I am quite
happy that I have successfully completed the project . With the
help of this project , I understood how to make a user-friendly
program , which in turn helped me to understand the various
programming methodologies .

BIBLIOGRAPHY
36

1. Computer Science C++ by Sumitha Arora

37

38

39

40

You might also like