By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,115 Members | 898 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,115 IT Pros & Developers. It's quick & easy.

i have project on hotel management in c++ but it is giving error

P: 1
it generates one error plz check urgent?
Expand|Select|Wrap|Line Numbers
  1. //  PROJECT ON HOTEL MANAGEMENT
  2.  
  3. # include <iostream.h>
  4. # include <conio.h>
  5. # include <dos.h>
  6. # include <iomanip.h>
  7. # include <GRAPHICS.H>
  8. # include <stdio.h>
  9. # include <string.h>
  10. # include <fstream.h>
  11. # include <stdlib.h>
  12. # include <ctype.h>
  13. # include <process.h>
  14.  
  15. fstream f,f1,f2,f3,f4,f5,f6,f7,f8;
  16.  
  17. //**********************************************************
  18. //    CLASS NAME : Hotel
  19. //    DETAILS    : IT CONTROLS OVER ALL FUNCTIONING
  20. //                   OF THE HOTEL
  21. //**********************************************************
  22. class HOTEL
  23. {
  24.     char array[100];
  25.     struct bill_restaurant_bar
  26.     {
  27.       long brestaurant,bbar;
  28.     } b[100];
  29.     struct booking_data
  30.     {
  31.       long charge,roomno;
  32.       char name[25],address[75],telno[10],date[11],roomtype[15];
  33.     } d;
  34.     struct check_out_data
  35.     {
  36.       char name[25],address[75],telno[10],date[11],odate[11],otime[6];
  37.       int roomno;
  38.     } C;
  39.     struct cancellation_data
  40.     {
  41.       char name[25],address[75],telno[10];
  42.     } D;
  43.     struct member_swimming_pool_data
  44.     {
  45.       char name[25],address[75],telno[10],date[11];
  46.       int memno;
  47.     } ms;
  48.     struct member_gym_data
  49.     {
  50.       char name[25],address[75],telno[10],date[11];
  51.       int memno;
  52.     } mg;
  53.     public:
  54.     void booking();
  55.     void check_in();
  56.     void check_out();
  57.     void cancellation();
  58.     void taxi_service();
  59.     void restaurant();
  60.     void bar();
  61.     void swimming_pool();
  62.     void gymnasium();
  63.     void games();
  64.     void view_data();
  65. }     H;
  66.  
  67.  
  68. //**********************************************************
  69. //    FUNCTION NAME       : BOOKING
  70. //**********************************************************
  71.  
  72. void HOTEL::booking ()
  73. {
  74.     textcolor(2);
  75.     clrscr();
  76.     int c=0;
  77.     //FINDING AN UNOCCUPIED ROOM
  78.     f.open("ARRAY.DAT",ios::in|ios::binary);
  79.     f.read((char *)&array,sizeof(array));
  80.     while(array[c]!='e') c++;
  81.     array[c]='o';
  82.     f.close();
  83.     f.open("ARRAY.DAT",ios::out|ios::binary);
  84.     f.write((char *)&array,sizeof(array));
  85.     f.close();
  86.     f1.open("HOT.EL",ios::app|ios::binary);
  87.     d.roomno=c+1;
  88.     //DATA OF THE CUSTOMER
  89.     cout<<"ENTER THE REQUIRED DATA
  90. "
  91.         <<"NAME :: ";
  92.     gets(d.name);
  93.     int l=strlen(d.name);
  94.     for(int i=0;i<l;i++) d.name[i]=toupper(d.name[i]);
  95.     cout<<"ADDRESS(R) :: ";
  96.     gets(d.address);
  97.     cout<<"TEL. NO.(R) :: ";
  98.     gets(d.telno);
  99.     cout<<"DATE WHEN YOU WILL CHECK-IN(dd/mm/yyyy) :: ";
  100.     gets(d.date);
  101.     cout<<"
  102.  
  103. ROOM TYPES  "<<"    "
  104.         <<"CODES"<<"    "<<"CHARGE PER DAY
  105. "
  106.         <<"ROYAL SUITE "<<"    "<<"1.   "<<"    "<<"Rs 20,000
  107. "
  108.         <<"SUPER DELUXE"<<"    "<<"2.   "<<"    "<<"Rs 15,000
  109. "
  110.         <<"DELUXE      "<<"    "<<"3.   "<<"    "<<"Rs 10,000
  111. "
  112.         <<"DOUBLE BED  "<<"    "<<"4.   "<<"    "<<"Rs  5,000
  113. "
  114.         <<"SINGLE BED  "<<"    "<<"5.   "<<"    "<<"Rs  2,000
  115. ";
  116.     int roomcode;
  117.     REDO:
  118.     cout<<"ROOM CODE :: ";
  119.     cin>>roomcode;
  120.     switch(roomcode)
  121.     {
  122.       case 1 : strcpy(d.roomtype,"ROYAL SUITE");
  123.            d.charge=20000;
  124.            break;
  125.       case 2 : strcpy(d.roomtype,"SUPER DELUXE");
  126.            d.charge=15000;
  127.            break;
  128.       case 3 : strcpy(d.roomtype,"DELUXE");
  129.            d.charge=10000;
  130.            break;
  131.       case 4 : strcpy(d.roomtype,"DOUBLE BED");
  132.            d.charge=5000;
  133.            break;
  134.       case 5 : strcpy(d.roomtype,"SINGLE BED");
  135.            d.charge=2000;
  136.            break;
  137.       default: cout<<"ENTER THE RIGHT CODE
  138. ";
  139.            goto REDO;
  140.     }
  141.     clrscr();
  142.     cout<<"YOUR ROOM NO. IS :: "<<d.roomno<<"
  143. ";
  144.     gotoxy(25,25);
  145.     cout<<"PRESS ANY KEY TO CONTINUE";
  146.     getch();
  147.     //COPYING THE RECORD OF THE CUSTOMER INTO A FILE
  148.     f1.write((char *)&d,sizeof(d));
  149.     f1.close();
  150.     clrscr();
  151. }
  152. void HOTEL::check_in()
  153. {
  154.     textcolor(12);
  155.     clrscr();
  156.     int rn;
  157.     char ans;
  158.     cout<<"HAVE YOU BOOKED IN ADVANCE ?(Y/N)::";
  159.     cin>>ans;
  160.     if(ans=='n'||ans=='N')
  161.     {
  162.       cout<<"THEN YOU FIRST HAVE TO BOOK";
  163.       gotoxy(25,25);
  164.       cout<<"PRESS ANY KEY TO CONTINUE";
  165.       getch();
  166.       booking();
  167.     }
  168.     clrscr();
  169.     cout<<"ROOM NUMBER   :: ";
  170.     cin>>rn;
  171.     f1.open("HOT.EL",ios::in|ios::binary);
  172.     do f1.read((char *)&d,sizeof(d)); while(d.roomno!=rn);
  173.     cout<<"NAME          :: "<<d.name<<"
  174. "
  175.         <<"ADDRESS(R)    :: "<<d.address<<"
  176. "
  177.         <<"TEL. NO.(R)   :: "<<d.telno<<"
  178. "
  179.         <<"CHECK-IN DATE :: "<<d.date<<"
  180. "
  181.         <<"ROOM TYPE     :: "<<d.roomtype;
  182.     gotoxy(25,25);
  183.     cout<<"PRESS ANY KEY TO CONTINUE";
  184.     getch();
  185.     f1.close();
  186.     clrscr();
  187. }
  188. void HOTEL::check_out()
  189. {
  190.     textcolor(10);
  191.     clrscr();
  192.     int rn;
  193.     cout<<"ROOM NUMBER :: ";
  194.     cin>>rn;
  195.     char od[11],ot[6];
  196.     cout<<"CHECK-OUT DATE (dd/mm/yyyy) :: ";
  197.     gets(od);
  198.     cout<<"CHECK-OUT TIME (in form of 07:30 , 22:55 etc) :: ";
  199.     gets(ot);
  200.     textcolor(6);
  201.     clrscr();
  202.     fstream e;
  203.     f1.open("HOT.EL",ios::in|ios::binary);
  204.     do{ f1.read((char *)&d,sizeof(d)); }while(d.roomno!=rn);
  205.     gotoxy(25,1); cout<<"**** BILL ****
  206.  
  207. ";
  208.     cout<<endl;
  209.     cout<<"        ROOM NUMBER       :: "<<d.roomno<<"
  210. "
  211.         <<"        NAME              :: "<<d.name<<"
  212. "
  213.         <<"        ADDRESS(R)        :: "<<d.address<<"
  214. "
  215.         <<"        TEL. NO.(R)       :: "<<d.telno<<"
  216. "
  217.         <<"        ROOM TYPE         :: "<<d.roomtype<<"
  218. "
  219.         <<"        CHECK-IN DATE     :: "<<d.date<<"
  220. "
  221.         <<"        CHECK-OUT DATE    :: "<<od<<"
  222. "
  223.         <<"        CHECK-OUT TIME    :: "<<ot<<"
  224. ";
  225.     //COPYING THE RECORD OF THE CUSTOMER INTO ANOTHER FILE
  226.     f2.open("C.OUT",ios::app|ios::binary);
  227.     strcpy(C.name,d.name);
  228.     strcpy(C.address,d.address);
  229.     strcpy(C.telno,d.telno);
  230.     strcpy(C.date,d.date);
  231.     strcpy(C.odate,od);
  232.     strcpy(C.otime,ot);
  233.     C.roomno=d.roomno;
  234.     f2.write((char *)&C,sizeof(C));
  235.     f2.close();
  236.     //CALCULATING NO. OF DAYS THE CUSTOMER OCCUPIED THE ROOM
  237.     //AND PRINTING THE TARIFF
  238.     long tariff;
  239.     int dd1,dd2,mm1,mm2,yy1,yy2,p,q,r;
  240.     dd1=(d.date[0]-48)*10+(d.date[1]-48);
  241.     dd2=(od[0]-48)*10+(od[1]-48);
  242.     mm1=(d.date[3]-48)*10+(d.date[4]-48);
  243.     mm2=(od[3]-48)*10+(od[4]-48);
  244.     yy1=(d.date[6]-48)*1000+(d.date[7]-48)*100+(d.date[8]-48)*10+(d.date[9]-48);
  245.     yy2=(od[6]-48)*1000+(od[7]-48)*100+(od[8]-48)*10+(od[9]-48);
  246.     if(yy1%4==0) { p=29; q=28; }
  247.     else if(yy2%4==0) { p=28; q=29; }
  248.     else { p=28; q=28; }
  249.     int cy[12]={ 31,p,31,30,31,30,31,31,30,31,30,31 };
  250.     int ny[12]={ 31,q,31,30,31,30,31,31,30,31,30,31 };
  251.     if(yy1==yy2 && mm1==mm2 && dd1==dd2) tariff=d.charge;
  252.     else
  253.     {
  254.       if(yy1==yy2)
  255.       {
  256.         if(mm1==mm2) tariff=d.charge*(dd2-dd1);
  257.         else
  258.         {
  259.           r=cy[mm1-1]-dd1+dd2;
  260.           for(int l=mm1;l<mm2-1;l++) r+=cy[l];
  261.           tariff=d.charge*r;
  262.         }
  263.       }
  264.       else
  265.       {
  266.         r=cy[mm1-1]-dd1+dd2;
  267.         for(int l=mm1;l<12;l++) r+=cy[l];
  268.         for(l=0;l<mm2-1;l++) r+=ny[l];
  269.         tariff=d.charge*r;
  270.       }
  271.     }
  272.     int c1,c2;
  273.     c1=(ot[0]-48)*10+(ot[1]-48);
  274.     c2=(ot[3]-48)*10+(ot[4]-48);
  275.     if(yy1==yy2 && mm1==mm2 && dd1==dd2);
  276.     else if(c1>12) tariff+=d.charge;
  277.     else if(c1==12 && c2>0) tariff+=d.charge;
  278.     cout<<"        TARIFF            :: Rs "<<tariff<<'
  279. ';
  280.     f1.close();
  281.     //SHOWING THE CUSTOMER'S RESTAURANT AND BAR BILL
  282.     f8.open("BILL.DAT",ios::in|ios::binary);
  283.     f8.read((char *)&b,sizeof(b));
  284.     cout<<"        RESTAURANT CHARGE :: Rs "<<b[rn-1].brestaurant<<'
  285. '
  286.         <<"        BAR CHARGE        :: Rs "<<b[rn-1].bbar<<'
  287. '
  288.         <<"        TOTAL             :: Rs "<<b[rn-1].brestaurant+b[rn-1].bbar+tariff;
  289.     b[rn-1].bbar=b[rn-1].brestaurant=0;
  290.     f8.close();
  291.     f8.open("BILL.DAT",ios::out|ios::binary);
  292.     f8.write((char *)&b,sizeof(b));
  293.     f8.close();
  294.     //DELETING THE RECORD OF THE CUSTOMER
  295.     f1.open("HOT.EL",ios::in|ios::binary);
  296.     e.open("F.DAT",ios::out|ios::binary);
  297.     f1.read((char *)&d,sizeof(d));
  298.     while(f1)
  299.     {
  300.       if(d.roomno!=rn)
  301.       {
  302.         e.write((char *)&d,sizeof(d));
  303.         f1.read((char *)&d,sizeof(d));
  304.       }
  305.       else f1.read((char *)&d,sizeof(d));
  306.     }
  307.     e.close();
  308.     f1.close();
  309.     f1.open("HOT.EL",ios::out|ios::binary);
  310.     e.open("F.DAT",ios::in|ios::binary);
  311.     e.read((char *)&d,sizeof(d));
  312.     while(e)
  313.     {
  314.       f1.write((char *)&d,sizeof(d));
  315.       e.read((char *)&d,sizeof(d));
  316.     }
  317.     e.close();
  318.     f1.close();
  319.     //MAKING THE ROOM OCCUPIED BY THE CUSTOMER AS UNOCCUPIED
  320.     f.open("ARRAY.DAT",ios::in|ios::binary);
  321.     f.read((char *)&array,sizeof(array));
  322.     array[rn-1]='e';
  323.     f.close();
  324.     f.open("ARRAY.DAT",ios::out|ios::binary);
  325.     f.write((char *)&array,sizeof(array));
  326.     f.close();
  327.     gotoxy(25,25);
  328.     cout<<"PRESS ANY KEY TO CONTINUE";
  329.     getch();
  330.     clrscr();
  331. }
  332. void HOTEL::cancellation()
  333. {
  334.     textcolor(1);
  335.     clrscr();
  336.     int rn;
  337.     cout<<"ROOM NUMBER  :: ";
  338.     cin>>rn;
  339.     f1.open("HOT.EL",ios::in|ios::binary);
  340.  
  341.     do f1.read((char*)&d,sizeof(d)); while(d.roomno!=rn);
  342.     cout<<"NAME         :: "<<d.name<<"
  343. "
  344.         <<"ADDRESS(R)   :: "<<d.address<<"
  345. "
  346.         <<"TEL. NO.(R)  :: "<<d.telno<<"
  347. "
  348.         <<"ROOM TYPE    :: "<<d.roomtype<<"
  349. "
  350.         <<"CANCELLED
  351. ";
  352.     //COPYING THE RECORD OF THE CUSTOMER INTO ANOTHER FILE
  353.     f3.open("CAN.CEL",ios::app|ios::binary);
  354.     strcpy(D.name,d.name);
  355.     strcpy(D.address,d.address);
  356.     strcpy(D.telno,d.telno);
  357.     f3.write((char *)&D,sizeof(D));
  358.     f3.close();
  359.     f1.close();
  360.     //MAKING THE ROOM ALLOTED TO THE CUSTOMER AS EMPTY
  361.     f.open("ARRAY.DAT",ios::in|ios::binary);
  362.     f.read((char *)&array,sizeof(array));
  363.     array[rn-1]='e';
  364.     f.close();
  365.     f.open("ARRAY.DAT",ios::out|ios::binary);
  366.     f.write((char *)&array,sizeof(array));
  367.     f.close();
  368.     fstream e;
  369.     //DELETING THE RECORD OF THE CUSTOMER
  370.     f1.open("HOT.EL",ios::in|ios::binary);
  371.     e.open("F1.DAT",ios::out|ios::binary);
  372.     f1.read((char *)&d,sizeof(d));
  373.     while(f1)
  374.     {
  375.       if(d.roomno!=rn)
  376.       {
  377.         e.write((char *)&d,sizeof(d));
  378.         f1.read((char *)&d,sizeof(d));
  379.       }
  380.       else f1.read((char *)&d,sizeof(d));
  381.     }
  382.     e.close();
  383.     f1.close();
  384.     f1.open("HOT.EL",ios::out|ios::binary);
  385.     e.open("F1.DAT",ios::in|ios::binary);
  386.     e.read((char *)&d,sizeof(d));
  387.     while(e)
  388.     {
  389.       f1.write((char *)&d,sizeof(d));
  390.       e.read((char *)&d,sizeof(d));
  391.     }
  392.     e.close();
  393.     f1.close();
  394.     gotoxy(25,25);
  395.     cout<<"PRESS ANY KEY TO CONTINUE";
  396.     getch();
  397.     clrscr();
  398. }
  399. void HOTEL::taxi_service()
  400. {
  401.     int gd=DETECT,gm,choice;
  402.     initgraph(&gd,&gm,"c:\tc\bgi");
  403.     settextstyle(10,0,1);
  404.     int x=40,y=10;
  405.     setcolor(BROWN);
  406.     outtextxy(50,20,"I am staying in this hotel");
  407.     outtextxy(x,y,".");
  408.     setcolor(CYAN);
  409.     outtextxy(50,60,"I am not staying in this hotel");
  410.     char W;
  411.     int count=0;
  412.     do
  413.     {
  414.       count++;
  415.       W=getch();
  416.       if(W=='
  417.  
Aug 24 '10 #1
Share this Question
Share on Google+
2 Replies


Oralloy
Expert 100+
P: 983
omer,

Your code cuts off at line 417.

Regardless of that, what's your specific problem?

Are you really expecting us to compile your program and find the error for ourselves?
Aug 24 '10 #2

weaknessforcats
Expert Mod 5K+
P: 9,197
Also, you are using very old C++ header files. iostream.h is pre-1998 C++. That is, non-ANS C++.

I couldn't compile your code if I wanted becuse of these old and obsolete headers.
Aug 25 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.