473,503 Members | 544 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

1 New Member
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
2 3623
Oralloy
988 Recognized Expert Contributor
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
9,208 Recognized Expert Moderator Expert
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

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

Similar topics

10
7354
by: Lakshmi Narayanan.R | last post by:
Hi Experts, Using keyword "To" in select case giving error.The following code is got from www.microsrosoft.com itself. What is the wrong with this?. <% Dim Number1 Number1 = 7 ' Initialize...
3
4399
by: db_from_mn | last post by:
Is it possible for properties in my deployment project to be read by my startup project? I want to show version info in an About Box. Or, am I going about this all wrong? Is there a...
7
1722
by: erin.sebastian | last post by:
Hello Everyone, This is my first attempt at coding using an abstract class and i am getting an error i can't figure out. Here is the back ground. I have a project that contains an abstract...
2
5715
by: Qiao Yun | last post by:
I used vc++.net (visual studio .net ) to open a project which can work well in vc++6.0. I succeeded in compiling the project in vc++.net in release mode . But when I tried to compile the project...
2
1471
by: Spam Catcher | last post by:
Hi all, Does anyone have a recommendation for a good issue tracker / project management application they use with their software projects and applications? We're currently using SourceGear...
1
2123
by: Ankur Goenka | last post by:
Hi, I am trying to include two proxy classes (from two different web services say Namespace.Service1 and Namespace.Service2) in a project (C# Class lib). These webservice internally use (as...
1
1459
by: Rahul Bhate | last post by:
Hello Sir My problem is in dos giving error that javac is not recognised.Tell me the steps for debugging.I have already set the CLASSPTH through command line & also set the PATH.But still giving...
4
1828
by: mukeshrasm | last post by:
<?php // create new document pdf_new(); $pdf = pdf_new(); pdf_open_file($pdf); pdf_begin_page($pdf, 500, 700); // define a font $font = pdf_findfont($pdf, "Courier", "host", 0);
4
4421
by: Abubakar | last post by:
Hi, I'm working on an application whose code was written by some other developer and I dont completely understand its source code right now. In one of the pages where I'm writing a test code, at...
7
2094
gskoli
by: gskoli | last post by:
Error - working in IE and MOzilla but giving error null or not a object: Guys i am giving you snippet of code , where it is javascript digital clock , It is showing time and working properly but...
0
7087
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7281
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7334
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5579
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3156
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1514
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
383
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.