Expand|Select|Wrap|Line Numbers
- // PROJECT ON HOTEL MANAGEMENT
- # include <iostream.h>
- # include <conio.h>
- # include <dos.h>
- # include <iomanip.h>
- # include <GRAPHICS.H>
- # include <stdio.h>
- # include <string.h>
- # include <fstream.h>
- # include <stdlib.h>
- # include <ctype.h>
- # include <process.h>
- fstream f,f1,f2,f3,f4,f5,f6,f7,f8;
- //**********************************************************
- // CLASS NAME : Hotel
- // DETAILS : IT CONTROLS OVER ALL FUNCTIONING
- // OF THE HOTEL
- //**********************************************************
- class HOTEL
- {
- char array[100];
- struct bill_restaurant_bar
- {
- long brestaurant,bbar;
- } b[100];
- struct booking_data
- {
- long charge,roomno;
- char name[25],address[75],telno[10],date[11],roomtype[15];
- } d;
- struct check_out_data
- {
- char name[25],address[75],telno[10],date[11],odate[11],otime[6];
- int roomno;
- } C;
- struct cancellation_data
- {
- char name[25],address[75],telno[10];
- } D;
- struct member_swimming_pool_data
- {
- char name[25],address[75],telno[10],date[11];
- int memno;
- } ms;
- struct member_gym_data
- {
- char name[25],address[75],telno[10],date[11];
- int memno;
- } mg;
- public:
- void booking();
- void check_in();
- void check_out();
- void cancellation();
- void taxi_service();
- void restaurant();
- void bar();
- void swimming_pool();
- void gymnasium();
- void games();
- void view_data();
- } H;
- //**********************************************************
- // FUNCTION NAME : BOOKING
- //**********************************************************
- void HOTEL::booking ()
- {
- textcolor(2);
- clrscr();
- int c=0;
- //FINDING AN UNOCCUPIED ROOM
- f.open("ARRAY.DAT",ios::in|ios::binary);
- f.read((char *)&array,sizeof(array));
- while(array[c]!='e') c++;
- array[c]='o';
- f.close();
- f.open("ARRAY.DAT",ios::out|ios::binary);
- f.write((char *)&array,sizeof(array));
- f.close();
- f1.open("HOT.EL",ios::app|ios::binary);
- d.roomno=c+1;
- //DATA OF THE CUSTOMER
- cout<<"ENTER THE REQUIRED DATA
- "
- <<"NAME :: ";
- gets(d.name);
- int l=strlen(d.name);
- for(int i=0;i<l;i++) d.name[i]=toupper(d.name[i]);
- cout<<"ADDRESS(R) :: ";
- gets(d.address);
- cout<<"TEL. NO.(R) :: ";
- gets(d.telno);
- cout<<"DATE WHEN YOU WILL CHECK-IN(dd/mm/yyyy) :: ";
- gets(d.date);
- cout<<"
- ROOM TYPES "<<" "
- <<"CODES"<<" "<<"CHARGE PER DAY
- "
- <<"ROYAL SUITE "<<" "<<"1. "<<" "<<"Rs 20,000
- "
- <<"SUPER DELUXE"<<" "<<"2. "<<" "<<"Rs 15,000
- "
- <<"DELUXE "<<" "<<"3. "<<" "<<"Rs 10,000
- "
- <<"DOUBLE BED "<<" "<<"4. "<<" "<<"Rs 5,000
- "
- <<"SINGLE BED "<<" "<<"5. "<<" "<<"Rs 2,000
- ";
- int roomcode;
- REDO:
- cout<<"ROOM CODE :: ";
- cin>>roomcode;
- switch(roomcode)
- {
- case 1 : strcpy(d.roomtype,"ROYAL SUITE");
- d.charge=20000;
- break;
- case 2 : strcpy(d.roomtype,"SUPER DELUXE");
- d.charge=15000;
- break;
- case 3 : strcpy(d.roomtype,"DELUXE");
- d.charge=10000;
- break;
- case 4 : strcpy(d.roomtype,"DOUBLE BED");
- d.charge=5000;
- break;
- case 5 : strcpy(d.roomtype,"SINGLE BED");
- d.charge=2000;
- break;
- default: cout<<"ENTER THE RIGHT CODE
- ";
- goto REDO;
- }
- clrscr();
- cout<<"YOUR ROOM NO. IS :: "<<d.roomno<<"
- ";
- gotoxy(25,25);
- cout<<"PRESS ANY KEY TO CONTINUE";
- getch();
- //COPYING THE RECORD OF THE CUSTOMER INTO A FILE
- f1.write((char *)&d,sizeof(d));
- f1.close();
- clrscr();
- }
- void HOTEL::check_in()
- {
- textcolor(12);
- clrscr();
- int rn;
- char ans;
- cout<<"HAVE YOU BOOKED IN ADVANCE ?(Y/N)::";
- cin>>ans;
- if(ans=='n'||ans=='N')
- {
- cout<<"THEN YOU FIRST HAVE TO BOOK";
- gotoxy(25,25);
- cout<<"PRESS ANY KEY TO CONTINUE";
- getch();
- booking();
- }
- clrscr();
- cout<<"ROOM NUMBER :: ";
- cin>>rn;
- f1.open("HOT.EL",ios::in|ios::binary);
- do f1.read((char *)&d,sizeof(d)); while(d.roomno!=rn);
- cout<<"NAME :: "<<d.name<<"
- "
- <<"ADDRESS(R) :: "<<d.address<<"
- "
- <<"TEL. NO.(R) :: "<<d.telno<<"
- "
- <<"CHECK-IN DATE :: "<<d.date<<"
- "
- <<"ROOM TYPE :: "<<d.roomtype;
- gotoxy(25,25);
- cout<<"PRESS ANY KEY TO CONTINUE";
- getch();
- f1.close();
- clrscr();
- }
- void HOTEL::check_out()
- {
- textcolor(10);
- clrscr();
- int rn;
- cout<<"ROOM NUMBER :: ";
- cin>>rn;
- char od[11],ot[6];
- cout<<"CHECK-OUT DATE (dd/mm/yyyy) :: ";
- gets(od);
- cout<<"CHECK-OUT TIME (in form of 07:30 , 22:55 etc) :: ";
- gets(ot);
- textcolor(6);
- clrscr();
- fstream e;
- f1.open("HOT.EL",ios::in|ios::binary);
- do{ f1.read((char *)&d,sizeof(d)); }while(d.roomno!=rn);
- gotoxy(25,1); cout<<"**** BILL ****
- ";
- cout<<endl;
- cout<<" ROOM NUMBER :: "<<d.roomno<<"
- "
- <<" NAME :: "<<d.name<<"
- "
- <<" ADDRESS(R) :: "<<d.address<<"
- "
- <<" TEL. NO.(R) :: "<<d.telno<<"
- "
- <<" ROOM TYPE :: "<<d.roomtype<<"
- "
- <<" CHECK-IN DATE :: "<<d.date<<"
- "
- <<" CHECK-OUT DATE :: "<<od<<"
- "
- <<" CHECK-OUT TIME :: "<<ot<<"
- ";
- //COPYING THE RECORD OF THE CUSTOMER INTO ANOTHER FILE
- f2.open("C.OUT",ios::app|ios::binary);
- strcpy(C.name,d.name);
- strcpy(C.address,d.address);
- strcpy(C.telno,d.telno);
- strcpy(C.date,d.date);
- strcpy(C.odate,od);
- strcpy(C.otime,ot);
- C.roomno=d.roomno;
- f2.write((char *)&C,sizeof(C));
- f2.close();
- //CALCULATING NO. OF DAYS THE CUSTOMER OCCUPIED THE ROOM
- //AND PRINTING THE TARIFF
- long tariff;
- int dd1,dd2,mm1,mm2,yy1,yy2,p,q,r;
- dd1=(d.date[0]-48)*10+(d.date[1]-48);
- dd2=(od[0]-48)*10+(od[1]-48);
- mm1=(d.date[3]-48)*10+(d.date[4]-48);
- mm2=(od[3]-48)*10+(od[4]-48);
- yy1=(d.date[6]-48)*1000+(d.date[7]-48)*100+(d.date[8]-48)*10+(d.date[9]-48);
- yy2=(od[6]-48)*1000+(od[7]-48)*100+(od[8]-48)*10+(od[9]-48);
- if(yy1%4==0) { p=29; q=28; }
- else if(yy2%4==0) { p=28; q=29; }
- else { p=28; q=28; }
- int cy[12]={ 31,p,31,30,31,30,31,31,30,31,30,31 };
- int ny[12]={ 31,q,31,30,31,30,31,31,30,31,30,31 };
- if(yy1==yy2 && mm1==mm2 && dd1==dd2) tariff=d.charge;
- else
- {
- if(yy1==yy2)
- {
- if(mm1==mm2) tariff=d.charge*(dd2-dd1);
- else
- {
- r=cy[mm1-1]-dd1+dd2;
- for(int l=mm1;l<mm2-1;l++) r+=cy[l];
- tariff=d.charge*r;
- }
- }
- else
- {
- r=cy[mm1-1]-dd1+dd2;
- for(int l=mm1;l<12;l++) r+=cy[l];
- for(l=0;l<mm2-1;l++) r+=ny[l];
- tariff=d.charge*r;
- }
- }
- int c1,c2;
- c1=(ot[0]-48)*10+(ot[1]-48);
- c2=(ot[3]-48)*10+(ot[4]-48);
- if(yy1==yy2 && mm1==mm2 && dd1==dd2);
- else if(c1>12) tariff+=d.charge;
- else if(c1==12 && c2>0) tariff+=d.charge;
- cout<<" TARIFF :: Rs "<<tariff<<'
- ';
- f1.close();
- //SHOWING THE CUSTOMER'S RESTAURANT AND BAR BILL
- f8.open("BILL.DAT",ios::in|ios::binary);
- f8.read((char *)&b,sizeof(b));
- cout<<" RESTAURANT CHARGE :: Rs "<<b[rn-1].brestaurant<<'
- '
- <<" BAR CHARGE :: Rs "<<b[rn-1].bbar<<'
- '
- <<" TOTAL :: Rs "<<b[rn-1].brestaurant+b[rn-1].bbar+tariff;
- b[rn-1].bbar=b[rn-1].brestaurant=0;
- f8.close();
- f8.open("BILL.DAT",ios::out|ios::binary);
- f8.write((char *)&b,sizeof(b));
- f8.close();
- //DELETING THE RECORD OF THE CUSTOMER
- f1.open("HOT.EL",ios::in|ios::binary);
- e.open("F.DAT",ios::out|ios::binary);
- f1.read((char *)&d,sizeof(d));
- while(f1)
- {
- if(d.roomno!=rn)
- {
- e.write((char *)&d,sizeof(d));
- f1.read((char *)&d,sizeof(d));
- }
- else f1.read((char *)&d,sizeof(d));
- }
- e.close();
- f1.close();
- f1.open("HOT.EL",ios::out|ios::binary);
- e.open("F.DAT",ios::in|ios::binary);
- e.read((char *)&d,sizeof(d));
- while(e)
- {
- f1.write((char *)&d,sizeof(d));
- e.read((char *)&d,sizeof(d));
- }
- e.close();
- f1.close();
- //MAKING THE ROOM OCCUPIED BY THE CUSTOMER AS UNOCCUPIED
- f.open("ARRAY.DAT",ios::in|ios::binary);
- f.read((char *)&array,sizeof(array));
- array[rn-1]='e';
- f.close();
- f.open("ARRAY.DAT",ios::out|ios::binary);
- f.write((char *)&array,sizeof(array));
- f.close();
- gotoxy(25,25);
- cout<<"PRESS ANY KEY TO CONTINUE";
- getch();
- clrscr();
- }
- void HOTEL::cancellation()
- {
- textcolor(1);
- clrscr();
- int rn;
- cout<<"ROOM NUMBER :: ";
- cin>>rn;
- f1.open("HOT.EL",ios::in|ios::binary);
- do f1.read((char*)&d,sizeof(d)); while(d.roomno!=rn);
- cout<<"NAME :: "<<d.name<<"
- "
- <<"ADDRESS(R) :: "<<d.address<<"
- "
- <<"TEL. NO.(R) :: "<<d.telno<<"
- "
- <<"ROOM TYPE :: "<<d.roomtype<<"
- "
- <<"CANCELLED
- ";
- //COPYING THE RECORD OF THE CUSTOMER INTO ANOTHER FILE
- f3.open("CAN.CEL",ios::app|ios::binary);
- strcpy(D.name,d.name);
- strcpy(D.address,d.address);
- strcpy(D.telno,d.telno);
- f3.write((char *)&D,sizeof(D));
- f3.close();
- f1.close();
- //MAKING THE ROOM ALLOTED TO THE CUSTOMER AS EMPTY
- f.open("ARRAY.DAT",ios::in|ios::binary);
- f.read((char *)&array,sizeof(array));
- array[rn-1]='e';
- f.close();
- f.open("ARRAY.DAT",ios::out|ios::binary);
- f.write((char *)&array,sizeof(array));
- f.close();
- fstream e;
- //DELETING THE RECORD OF THE CUSTOMER
- f1.open("HOT.EL",ios::in|ios::binary);
- e.open("F1.DAT",ios::out|ios::binary);
- f1.read((char *)&d,sizeof(d));
- while(f1)
- {
- if(d.roomno!=rn)
- {
- e.write((char *)&d,sizeof(d));
- f1.read((char *)&d,sizeof(d));
- }
- else f1.read((char *)&d,sizeof(d));
- }
- e.close();
- f1.close();
- f1.open("HOT.EL",ios::out|ios::binary);
- e.open("F1.DAT",ios::in|ios::binary);
- e.read((char *)&d,sizeof(d));
- while(e)
- {
- f1.write((char *)&d,sizeof(d));
- e.read((char *)&d,sizeof(d));
- }
- e.close();
- f1.close();
- gotoxy(25,25);
- cout<<"PRESS ANY KEY TO CONTINUE";
- getch();
- clrscr();
- }
- void HOTEL::taxi_service()
- {
- int gd=DETECT,gm,choice;
- initgraph(&gd,&gm,"c:\tc\bgi");
- settextstyle(10,0,1);
- int x=40,y=10;
- setcolor(BROWN);
- outtextxy(50,20,"I am staying in this hotel");
- outtextxy(x,y,".");
- setcolor(CYAN);
- outtextxy(50,60,"I am not staying in this hotel");
- char W;
- int count=0;
- do
- {
- count++;
- W=getch();
- if(W=='