Sie sind auf Seite 1von 48




Department of Computer science And Engineering Institute Of Engineering And Technologies Kaushambi Allahabad (U.P.)

Candidate Declaration
I hereby certify that the work which is being presented in the entitled project ONLINE TICKETING using J2EE in fulfillment of the course curriculum requirement for the subject J2EE And Design of the degree of Bachelor of Engineering and Technology and submitted in the Computer Engineering Department of SPMIT, Allahabad, is an authentic record of our own work being carried out during a period from July 12, 20011 to August 13, 20011, under the supervision of Ms. Ashish Mishra .

Shipra Jaiswal CS 7th Sem


This project ONLINE TICKETING using J2EE is an effort to show the details of a particular out/in customer in the Reservation System. It is pleasure to acknowledge with deep sense of gratitude for the invaluable help and guidance rendered by my project guide Sir Ashish Mishra under whose guidance I have been able to complete my project. I pen off with thanks to everyone including the faculty, staff members of my institute who had helped me from time to time in successful completion of my project.


1. Introduction. 2. Project selection. 3. Feasibility study, Requirement. 4. Language selection. 5. Design phase DFD. 6. Outputs. 7. Coding. 8. Bibliography. 9. Limitation of the project.


Online Ticketing is a project made in J2EE which enables to make the computerization of Online Reservation System. By just sitting on the computer one can reserve availability of sits and billing system etc. This project is very easy to use and simply editing the record does the maintenance of the records. Interface of the records is made simple so that everyone may use this project easily. By using the project one can easily maintain the customer records and save the necessary information into the files and easily remove the information which is not required.



The present era is the business era. Traveling forms an important part of the business era. We being the future computer engineers, realize the importance of traveling by trains. Amongst the various projects in option, I found the project on Online ticketing as the most appropriate one as it deals with reservation of trains. It can replace the manual system of reservation in the with an easy, time saving and more secure system. Indian Railways is more than150 year old It is largest railway system in world under one management It is a lifeline of country It is biggest civilian employer in the world No strike in last 30 years in spite of 17 lakh workers Always targeted by public during any rally, agitation etc



Problem Analysis
In Hotel Reservation System we need an automated courses information regarding availability of suite, type of suite available, records of the customer, check in and check out time of the customer, for how many days the customer is going to book the room and substantial information and charges accordingly. Daily enquiry and enrollment information like booking of the rooms, keeping the customers check in time and check out time, bills for the time he stayed in the hotel and deleting a particular customers information completely after his departure. This also provide user to enquire about a particular room.

Limitation of Existing System

1. Presently this work is done manually. 2. The manual System is dependent on the person who is handling and not system dependent. It means that the person, who has created it, can understand its skills and knowledge can be handled by anybody by having little knowledge about the software i.e. it is system dependent. 3. As human brain is prone to tiredness, the efficiency reduces as well as system is bounded to have more errors and does calculation mistakes. 4. Redundancy is also one of the hindrances in manual system. As data is duplicated at many different places modification at one place and not to another will led to errors.


We already have Hotel Reservation System that is being run manually. Different persons are assigned for different jobs, as one person is to maintain the records of the customers i.e. busy in making booking of the rooms, the other is busy with managing the details of availability of rooms, the other is busy with maintaining the bills, that is we can say separate persons are employed for different jobs. So the basic problem faced with this system is if one wants to get information for a room, then one has to go to the other person for room availability then to other for booking of the room. Also there can be multiple entries for same room. So there are more and more chances of error so the system should be able to check the errors.


In my project I have tried to save the most precious thing that is time, which is very valuable in an organization in todays world. Keeping this in mind I have tried to make the manual system of keeping the record to a computerized system in which a person sitting on his PC can maintain all the record of the hotel reservation system and can get all the updated information of all the rooms and customers at any time easily on his PC. The user needs not to see any document in the file and to concern any other person.



The purpose of this document is to describe all the external requirements for a manual management for a manual management system. It also describes the interface of the system.

This document is the only one that describes the requirements of the system. It is meant for use by the developers and will also be base for validating the final delivered system. Any change made to the requirements in future will have to go through a formal change approval process the developer is responsible for asking the clarification where necessary and will not make any alterations.


Keyboard and Mouse. 4 GB Hard disk or more. 64 MB RAM or more. Floppy Disk Drive / CD/DVD-ROM Drive. 15 or greater color Monitor.


Windows 95 or higher. Turbo C++ compiler.


The user requirements which are covered in this project are as: 1. Automated facility for booking a room in the hotel i.e. allotment of rooms etc. 2. Automated facility for updating the records of a customer when he vacates the room. 3. Automated facility for viewing the records of a particular customer in the hotel i.e. name of the customer, native place of the customer, identification number of the customer and room number of the customer. 4. Automated facility for viewing the list of the customers along with his detailed information. 5. Automated facility to check room status i.e. how many rooms in the hotel are vacant and how many are booked. 6. Computerized billing system i.e. when a customer vacates a room, the bills for the days he stayed in the hotel are calculated automatically.



Why I choose C++ over C?

We change over structure programming to object oriented programming because: When a program designed using the structured programming paradigm grows a certain limit it becomes unmanageable on two counts: 1. The program does not have enough flexibility to meet the rapidly changing demands of typical business environment. This is because even a well designed structured system does not have much scope for reusing its existing subsystem in future to meet the changing business requirement. Even in a well designed structures system enhancements often require modification to significant portions of existing design and code. As against this, object oriented programming systems reuse of existing code through features like:

Class and Object: A class is a design. Object is the creation of this design. Multiple objects can be created to form a single class. The class defines the type of object that can be created according to the data the object can hold and the operations the object can perform.


Inheritance: It is the process by which objects of one class acquire the properties of objects of another class. The concept of inheritance provides the idea of reusability.


Polymorphism: Polymorphism means the ability to assume several forms. In object oriented programming context this refers to the ability of an entity to refer to objects of various classes at run time.

C++ has three mechanisms that help us to implement polymorphism. These are: 1. Function overloading. 2. Operator overloading. 3. Virtual functions.

Encapsulation: The wrapping up of data and function in to a single unit (called class) is known as encapsulation. The data is not accessible to the out side world and nobly those functions which are in class can access it. This insulation of the data from direct access of the program is called data hiding or information hiding.


Dynamic Binding: Binding refers to the linking of procedure call to the code to be executed in response to the called. Dynamic binding means that the code associated with a given procedure call is not known until the time of call at run time.


Abstraction: Abstraction refers to the act of representing essential features without including background details or explanation.

2. The software built around structured programming paradigm is difficult to maintain, especially so when the person maintaining the program is not from the original development team. 3. Being a block structured programming language we can save memory by controlling the life of the variable. 4. Documentation of project in C++ is better than in C.



The most creative and challenging phase of the system life cycle is SYSTEM DESIGN. The term design describes a final system and the process by which it is developed. It refers to the technical specification that will be applied in implementing the candidate system. It also includes the construction of program and program testing. The key question here is: How should the problem be solved? Design Phase Is Basically Of Two Types: 1. Traditional Design Phase. 2. Object Oriented Design Phase. But we normally follow the traditional design in the form of DFDs. DFD is also known as a bubble chart, has a purpose of clarifying system requirements. And identifying major transformation that will become programs in system design. DFDs consists of a series of bubbles joined by lines. The bubbles represent data transformation and represent data flow.

The following are the symbols that are used in making a DFD:

AN OPEN RECTANGLE is a data store data at rest, or a temporary repository of data.


A SQUARE defines a source or destination of system data.


AN ARROW identifies flow-data in motion. It is pipelined through which information which information flows.

A CIRCLE or bubbles represent a process that transforms incoming data flow into outgoing data flows.



































**********>HOTEL RESERVATION SYSTEM<**********

1. Customer Record. 2. Room Status. 3. Make Booking. 4. Cancellation. 5. Customer List. 6. Bills. 7. Quit. Enter Your Choice:

Enter Your Choice: 2

Total Number Of Single Room Suites: 10 Total Number Of Double Room Suites: 10 There Are 0 Rooms Occupied In The Hotel 10 Single Room Suites Are Available. 10 Double Room Suites Are Available.

Enter Your Choice: 3

The Charges For Single Room Suite Are: Rs.350 The Charges For Double Room Suite Are: Rs.500 Enter Customers Data:Enter Customers Name: Karan Enter Occupants Native Place: Nalagarh Enter Occupants Identity Number: 3 Enter Check In Date (dd mm yy): 12 04 07 Enter The Suite Type: Single Or Double (s/d): s Single Room Suites Available: 9 Double Room Suites Available: 10 Room Number 1 is Booked For You.

Enter Your Choice: 2

Total Number Of Single Room Suites: 10. Total Number Of Double Room Suites: 10. There Are 1 Rooms Occupied In The Hotel. 9 Single Room Suites Are Available. 10 Double Room Suites Are Available.

Enter Your Choice: 1

Enter Identity Number: 3 The Occupants Name Is : Karan The Occupants Native Place Is: Nalagarh The Check In Date Is: 12 04 07 The Identity Number Is: 3

Enter Your Choice: 6

The Rental Charges For Single Room Suite Is: Rs.350 The Rental Charges For Double Room Suite Is : Rs.500 Enter The Number Of Days Stayed: 2 Enter Identity Number: 3 The Occupants Name Is: Karan The Occupants Native Place Is: Nalagarh The Check In Date Is: 12 4 07 The Identity Number Is: 3 The Check Out Date Is: 14 4 07 Enter The Type Of SuiteSingle or Double (s/d): s Total Amount Payable: Rs.700

Enter Your Choice: 5

The Occupants Name Is: Karan The Occupants Native Place Is: Nalagarh The Check In Date Is: 12 4 07 The Identity Number Is : 3 The Occupants Name Is: Himanshu The Occupants Native Place Is: Chandigarh The Check In Date Is: 8 5 07 The Identity Number Is: 5

Enter Your Choice: 4

Do You Want To Vacate A Room? (y/n) y Enter The Suite Type Of Room Single or Double (s/d): s Enter The Room Number To be Vacated: 1 Enter Identity Number: 3 The Occupants Name Is: Karan The Occupants Native Place Is: Nalagarh The Check In Date Is: 12 4 07 The Identity Number Is: 3 The Room Is Vacated. Total Number Of Single Room Suites: 10 Total Number Of Double Room Suites: 10 There Are 0 Rooms Occupied In The Hotel. 10 Single Room Suites Are Available. 10 Double Room Suites Are Available.


//********************************************************************** // HOTEL MANAGEMENT SYSTEM //********************************************************************** //***********Header Files Included************* #include<stdio.h> #include<conio.h> #include<dos.h> #include<ctype.h> #include<stdlib.h> #include<fstream.h> #include<process.h> #include<graphics.h> void interface(); class customer { private: char name[20],n_place[10]; int dd,mm,yy,n,i,dd1,mm1,yy1,roomno; public: int st1,st2; customer() { st1=10; st2=10; } customer(int x,int y) { st1=x; st2=y; } //Function Declared //***********************Class Customer Begins****************************

int IN; void getdata(); void displaydata(); void status(); void vacate(); void bill(); }c; //****************************Class Customer Ends********************* //************This Function Displays The Interface Of The Project************ void interface() { //Request Autodetection int gdriver = DETECT, gmode, errorcode; int midx, midy, i; int xradius = 100, yradius = 50; //initialize Graphics And Local Variables initgraph(&gdriver, &gmode, "C:\\tc\\bgi"); //Read Result Of Initialization errorcode = graphresult(); if(errorcode != grOk) //An Error Occurred { printf("Graphics Error : %s\n",grapherrormsg(errorcode)); printf("Press Any Key To Halt : "); getch(); exit(1); //Terminate With An Error Code } midx = getmaxx()/2; midy = getmaxy()/2; setcolor(WHITE); setbkcolor(6); setfillstyle(1,4);

fillellipse(midx, midy, 200, 200); setfillstyle(1,3); fillellipse(midx, midy, 155, 155); setfillstyle(1, 1); fillellipse(midx, midy, xradius, yradius); settextstyle(TRIPLEX_FONT, HORIZ_DIR, 4); setusercharsize(3,1,1,1); outtextxy(180,155,"Hotel"); outtextxy(22,220,"Reservation"); outtextxy(150,285,"System"); getch(); clrscr(); setcolor(RED); setusercharsize(1,1,1,1); settextstyle(GOTHIC_FONT,HORIZ_DIR,5); outtextxy(160,150,"Compiled By : "); settextstyle(TRIPLEX_FONT,HORIZ_DIR,3); outtextxy(210,200,"Raghu "); outtextxy(210,225,"Sunny"); outtextxy(210,250,"Venus"); outtextxy(210,275,"Vineet"); getch(); closegraph(); } //************This Function Takes The Customer's Data As Input************** void customer::getdata() { cout<<"\n\n\tThe Charges For Single Room Suites Are : Rs.350 Only "<<endl; cout<<"\n\tThe Charges For Double Room Suites Are : Rs.500 Only "<<endl; cout<<"\n\n\tEnter Customer's Data : "; cout<<"\n\tEnter Occupant's Name : ";

fflush(stdin); gets(name); cout<<"\n\n\t Enter Occupant's Native Place : "; fflush(stdin); gets(n_place); cout<<"\n\n\t Enter Occupant's Identity Number : "; fflush(stdin); cin>>IN; cout<<"\n\n\t Enter Check In Date (dd mm yy) : "; fflush(stdin); cin>>dd>>mm>>yy; char ch; cout<<"\n\t Enter The Suite Type : Single(s) Or Double(d) : "; fflush(stdin); cin>>ch; if(ch=='s') { st1=st1-1; st2=st2; cout<<"\n\tSingle Room Suites Available: "<<st1<<endl; cout<<"\tDouble Room Suites Available : "<<st2<<endl; customer(st1,st2); cout<<"\n\t Room Number "<<(10-st1)<<" Is Booked For You. "; getch(); } else if(ch=='d') { st1=st1; st2=st2-1; cout<<"\n\tSingle Room Suites Available : "<<st1<<endl; cout<<"\tDouble Room Available : "<<st2<<endl;

customer(st1,st2); cout<<"\n\tRoom Number "<<(20-st2)<<" Is Booked For You. "; getch(); } } //****************This Function Displays The Customer's Data***************** void customer::displaydata() { clrscr(); fflush(stdin); cout<<"\n\n\t The Occupant's Name Is : "<<name<<endl; cout<<"\t The Check In Date Is : "<<dd<<" "<<mm<<" "<<yy<<endl; cout<<"\t The Identity Number Is : "<<IN<<endl; getch(); } //***************This Function Displays The Current Room Status*************** void customer::status() { fflush(stdin); cout<<"\n\n Total Number Of Single Room Suits : 10"; cout<<"\n Total Number Of Double Room Suits : 10"; cout<<"\n\n There Are "<<(20-(st1+st2))<<" Rooms Occupied In The Hotel "; cout<<"\n\n "<<st1<<" Single Room Suits Are Available "; cout<<"\n "<<st2<<" Double Room Suits Are Available "; getch(); } //*****************This Function Vacates The Room********************** void customer::vacate() { clrscr(); char ch4,ch;

int rno,ch2; cout<<"\n Do You Want To Vacate A Room? (y/n) "; fflush(stdin); cin>>ch4; if(ch4=='y') { cout<<"\nEnter The Suite Type Of Room -> Single Or Double (s/d) : "; fflush(stdin); cin>>ch; cout<<"\n Enter The Room Number To Be Vacated : "; fflush(stdin); cin>>rno; fstream file;"Customer.dat",ios::binary|ios::app|ios::in); cout<<"\n\n Enter Identity Number : "; fflush(stdin); cin>>ch2; file.seekg(0,ios::beg); if(*)&c,sizeof(c))); while(!file.eof()) { if(ch2==c.IN) { displaydata(); } if(*)&c,sizeof(c))); } file.close(); if(rno<=10) { st1=st1+1;

st2=st2; customer(st1,st2); file.write((char*)&c,sizeof(c)); } else if(rno>10) { st1=st1; st2=st2+1; customer(st1,st2); file.write((char*)&c,sizeof(c)); } file.close();"customer.dat",ios::binary|ios::in); fstream temp;"temp.dat",ios::binary|ios::out); file.seekg(!file.eof()); while(!file.eof()) { if(*)&c,sizeof(c))); if(file.eof()) break; if(ch2!=c.IN) temp.write((char*)&c,sizeof(c)); } file.close(); temp.close();"customer.dat",ios::binary|ios::out);"temp.dat",ios::binary|ios::in); file.seekp(0,ios::beg); temp.seekg(0,ios::beg); while(!temp.eof())

{ if(*)&c,sizeof(c))); if(temp.eof()) break; file.write((char*)&c,sizeof(c)); } file.close(); temp.close(); cout<<"\n The Room Is Vacated. "; c.status(); getch(); } else { clrscr(); } } //************This Function Calculates The Bill For The Customer************* void customer::bill() { int no,i; clrscr(); gotoxy(10,8); cout<<"\n\n The Rental Charges For Single Room Suite Is : Rs.350 "; cout<<"\n\n The Rental Charges For Double Room Suite Is : Rs.500 "; cout<<"\n\n Enter The Number Of Days Stayed : "; fflush(stdin); cin>>no; cout<<"\n\t Enter Identity Number : "; fflush(stdin); cin>>i;

ifstream infile;"customer.dat",ios::binary); infile.seekg(0,ios::beg);*)&c,sizeof(c)); while(infile) { if(i==c.IN) { c.displaydata(); }*)&c,sizeof(c)); } infile.close(); cout<<"\n\n Enter Check Out Date : "; fflush(stdin); cin>>dd1>>mm1>>yy1; char ar; cout<<"\n\n\n Enter The Type Of Suite-->Single Or Double(s/d) : "; fflush(stdin); cin>>ar; ar=toupper(ar); switch(ar) { case 's': { cout<<"\n\n\t Total Amount Payable : Rs."<<(350*no); break; } case 'd': { cout<<"\n\n\t Total Amount Payable : Rs."<<(500*no);

break; } } getch(); } //*************************The Main Function**************************** void main() { clrscr(); interface(); customer c; int t,d,e,ti,j,y,no; do { textcolor(WHITE); textbackground(RED); clrscr(); gotoxy(9,4); cout<<"******************> HOTEL MANAGEMENT SYSTEM <******************"; gotoxy(20,8); cout<<"1.Customer Record. "; gotoxy(20,10); cout<<"2.Room Status. "; gotoxy(20,12); cout<<"3.Make Booking. "; gotoxy(20,14); cout<<"4.Cancellation. "; gotoxy(20,16); cout<<"5.Customer List. "; gotoxy(20,18);

cout<<"6.Bills. "; gotoxy(20,20); cout<<"7.Quit. "; gotoxy(20,24); fflush(stdin); cout<<"Enter Your Choice : "; cin>>no; if(no<=0||no>7) { gotoxy(10,24); cout<<"Please Enter Valid Choice Only "; main(); getch(); } switch(no) { case 1: //Displays The Data Of A Particular Customer { clrscr(); int ch2; ifstream infile;"customer.dat",ios::binary); cout<<"\n\n Enter Identity Number : "; fflush(stdin); cin>>ch2; infile.seekg(0,ios::beg);*)&c,sizeof c); while(infile) { if(ch2==c.IN) {

c.displaydata(); }*)&c,sizeof c); } infile.close(); getch(); break; } case 2: { clrscr(); fstream file;"customer.dat",ios::binary|ios::app); c.status(); file.write((char*)&c,sizeof(c)); file.close(); getch(); break; } case 3: { clrscr(); ofstream outfile;"customer.dat",ios::binary|ios::app); c.getdata(); outfile.write((char*)&c,sizeof(c)); outfile.close(); getch(); break; } case 4: //Vacates The Room //Books A Room For The Customer //Displays The Room Status

{ clrscr(); c.vacate(); getch(); break; } case 5: { clrscr(); ifstream infile;"customer.dat",ios::binary); infile.seekg(0,ios::beg);*)&c,sizeof c); while(infile) { c.displaydata();*)&c,sizeof c); } infile.close(); getch(); break; } case 6: { clrscr(); c.bill(); getch(); break; } case 7: { //Exits From The Main Menu //Calculate The Bill For The Customer //Displays The List Of All Customers In The Hotel

clrscr(); exit(0); break; } } } while(no>0 && no<=7); getch(); } //********************************************************************** //*************************END OF PROGRAM*************************** //**********************************************************************


1. Object Oriented Programming With C++ 2. Object Oriented Programming In C++ 3. The C++ Programming Language 4. C++ And Graphics

E.Balagurusamy Robert Lafore Bjarne Stroustrup Meeta Gandhi, Rajiv Shah, Tilak Shetty

5. System Analysis And Design

Elias M.Awad


Hotel Reservation System Project has some following limitations:

It is not password protected. No graphical user interface. File of Mess is not included to keep a check on project complexity. Rooms and their Price are fixed.