7 Replies - 5686 Views - Last Post: 25 March 2011 - 08:01 AM Rate Topic: -----

#1 happysajitha  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 25-March 11

Problem with the update and booking section

Posted 25 March 2011 - 12:59 AM

Dear members,
I am a SE(CSE) student. I m completing a mini-project on BUS RESERVATION SYSTEM. I have ended up on a problem with the update and booking section. We r trying the program using file handling in c++. We have tried with most of the part but just have got this problem.
Please provide me with the necessary guidance and the logic if u can.
Is This A Good Question/Topic? 0
  • +

Replies To: Problem with the update and booking section

#2 Jeff H  Icon User is offline

  • D.I.C Regular

Reputation: 112
  • View blog
  • Posts: 308
  • Joined: 30-January 11

Re: Problem with the update and booking section

Posted 25 March 2011 - 01:18 AM

With the information given the best guidance I could give is fix the problem in update and booking section.
Was This Post Helpful? 1
  • +
  • -

#3 happysajitha  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 25-March 11

Re: Problem with the update and booking section

Posted 25 March 2011 - 01:39 AM

hi,
I have done woth most part of my project and am asking u to provide some suggestions to help me out with problem of update section.
Was This Post Helpful? 0
  • +
  • -

#4 newclearner  Icon User is offline

  • D.I.C Regular

Reputation: 103
  • View blog
  • Posts: 302
  • Joined: 29-September 10

Re: Problem with the update and booking section

Posted 25 March 2011 - 02:06 AM

And what exactly the problem is? For providing you some suggestions we need to see your code and need to know what issues you are facing?

Asking for random sugesstion is going to get you a random answer which might not be of any help. Garbage-In, Garbage-out. Be specific.
Was This Post Helpful? 1
  • +
  • -

#5 happysajitha  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 25-March 11

Re: Problem with the update and booking section

Posted 25 March 2011 - 02:21 AM

I have provided below the partially completed code of my mini-project. Help me if u can................

/*MINI PROJECT ON BUS RESERVATION SYSTEM*/

#include<conio.h>
#include<stdio.h>
#include<iostream.h>
#include<string.h>
#include<fstream.h>
#include<graphics.h>
#include<stdlib.h>
#include<dos.h>

class bus
{
int busn,s,fare,i;
char driver[10],arrival[5],depart[5],to[10],seat/*[8][4]*/,date[10],pas_name[20];

fstream x,z;

public:
	void pass()
	{
	int i=0;
	char p[6];
	clrscr();

	cout<<"\n\n\n\n\n\t\t\tEnter password:";

		for(i=0;i<6;i++)
		{
		p[i]=getch();
		cout<<"*";
		}
		p[i]='\0';

		if(strcmp("smokie",p)==0)
		{
		getch();
		cout<<"\n\n\n\t\t\tPassword correct";
		cout<<"\n\n\t\t\tPress Any To Continue.....";
		getch();
		}
		else
		{
		getch();
		cout<<"\n\n\n\t\t\tIncorrect password";
		getch();
		exit(0);
		}
	}

	void install()
	{
	clrscr();
	z.open("data.txt",ios::app);

	for(i=0;i<1;i++)
	{
	cout<<"\n\tSource:Kolhapur";
	cout<<"\n\tEnter bus no: ";
	cin>>busn;
	cout<<"\n\tEnter driver's name: ";
	cin>>driver;
	cout<<"\n\tEnter destination:";
	cin>>to;
	cout<<"\n\tEnter fares:";
	cin>>fare;
	cout<<"\n\tEnter arrival time: ";
	cin>>arrival;
	cout<<"\n\tEnter departure time: ";
	cin>>depart;
	cout<<"\n\tEnter date (dd/mm/yy):";
	cin>>date;
	z<<busn<<"\t"<<driver<<"\t"<<to<<"\t"<<fare<<"\t"<<arrival<<"\t"<<depart<<"\t"<<date<<endl;
	}
	z.close();
	getch();
	}

	void show()
	{
	int ch1;
	clrscr();
	clrscr();
	z.open("emp.txt",ios::in);
	cout<<"\n\n\n***** SHOW *****\n\n1.Seatwise reservation details\n";
	cout<<"2.Bus reservation details\n\nEnter choice:";
	cin>>ch1;
	clrscr();

	switch(ch1)
	{
	case 1:
	cout<<"Enter Bus no.:";
	cin>>busn;
	cout<<"Enter seat no.:";
	cin>>seat;
	cout<<"\n\tBus no.:"<<busn;
	cout<<"\n\tDriver's name:"<<driver;
	cout<<"\n\tSeat no.:"<<seat;
	cout<<"\n\tPassenger name:"<<pas_name;
	cout<<"\n\tFrom:Kolhapur"<<"\t\t\t\t"<<"To:"<<to;
	cout<<"\n\tFare:Rs.",fare;
	cout<<"\n\tDate:%s",date;
	cout<<"\n\tArrival time:"<<"\t\t\t\t"<<"Departure time:"<<depart;
	break;

	case 2:
	cout<<"\n\n\nBus no.:"<<busn;
	cout<<"\t\t\tDriver's name:"<<driver;
	cout<<"\n\nSeat no.:"<<seat;
	cout<<"\t\t\tPassenger name:"<<pas_name;
	cout<<"\n\nFrom:Kolhapur"<<"\t\t\t"<<"To:"<<to;
	cout<<"\n\nDate:"<<date;
	cout<<"\n\nArrival time:"<<arrival<<"\t\t"<<"Departure time:"<<depart;
	cout<<"\n\n********************************************************************************\n";

     /* for(s=0;s<32;s++)
	{
	}*/
	break;
	}
	}
    };

void main()
{
clrscr();
bus b;
int w,gd=DETECT,gm,ch;
initgraph(&gd,&gm,"c:\\tc\\bgi");//enter the path of ur c compiler where u installed it.
setbkcolor(BLUE);

//do{
cout<<"\n\n\t\t\t***** BUS RESERVATION SYSTEM *****\n\n\n\t\t\t\t-*-*-*-MENU-*-*-*-\n\n\t\t\t\t1.Install\n\t\t\t\t2.Booking\n\t\t\t\t3.Update\n\t\t\t\t4.Show\n\t\t\t\t5.Cancellation\n\t\t\t\t6.Enquiry\n\t\t\t\t7.Exit\nEnter choice:";
cin>>ch;

switch(ch)
{
	case 1: b.install();
		break;
       /*	case 2: booking();
		break;
	case 3: update();
		break;*/
	case 4: b.show();
		break;
       /*	case 5: cancel();
		break;*/
/*	case 6: b.enquiry();
		break;*/
	case 7: exit(0);
		//break;
}
//}while(ch!=7);
getch();
}


MOD EDIT: When posting code...USE CODE TAGS!!!

:code:

This post has been edited by JackOfAllTrades: 25 March 2011 - 04:16 AM

Was This Post Helpful? 0
  • +
  • -

#6 newclearner  Icon User is offline

  • D.I.C Regular

Reputation: 103
  • View blog
  • Posts: 302
  • Joined: 29-September 10

Re: Problem with the update and booking section

Posted 25 March 2011 - 03:11 AM

1. Did you see the watermark in the message box while typing that asked you to type your code in code tags? Edit your last post and post your code between [code] tags if you want to get help.

2. Are you using Turbo C compiler?
Was This Post Helpful? 0
  • +
  • -

#7 happysajitha  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 25-March 11

Re: Problem with the update and booking section

Posted 25 March 2011 - 06:26 AM

Yes, I am using a Turbo c Complier
Also I am having a problem in the password section. If the password function is called the rest of the program starts getting error. I am not getting exactly what to do so have left the function in comments.

/*MINI PROJECT ON BUS RESERVATION SYSTEM*/

#include<conio.h>
#include<stdio.h>
#include<iostream.h>
#include<string.h>
#include<fstream.h>
#include<graphics.h>
#include<stdlib.h>
#include<dos.h>

class bus
{
int busn,s,fare,i,seat;
char driver[10],arrival[5],depart[5],to[10],date[10],pas_name[20];

fstream x,z;

public:
	void install()
	{
	clrscr();
	z.open("data.txt",ios::app);

	cout<<"\n\n\t\t\t***** BUS RESERVATION SYSTEM *****\n\n";
	cout<<"\t\t\t*******INSTALL*******\n\n";
	for(i=0;i<1;i++)
	{
	cout<<"\n\tSource:Kolhapur";
	cout<<"\n\tEnter bus no: ";
	cin>>busn;
	cout<<"\n\tEnter driver's name: ";
	cin>>driver;
	cout<<"\n\tEnter destination:";
	cin>>to;
	cout<<"\n\tEnter fares:";
	cin>>fare;
	cout<<"\n\tEnter arrival time: ";
	cin>>arrival;
	cout<<"\n\tEnter departure time: ";
	cin>>depart;
	cout<<"\n\tEnter date (dd/mm/yy):";
	cin>>date;
	z<<busn<<"\t"<<driver<<"\t"<<to<<"\t"<<fare<<"\t"<<arrival<<"\t"<<depart<<"\t"<<date<<endl;
	}
	z.close();
	getch();
	}

	void show()
	{
	int ch1;
	clrscr();
	z.open("data.txt",ios::in);
	cout<<"\n\n\t\t\t***** BUS RESERVATION SYSTEM *****\n\n";
	cout<<"\t\t\t\t***** SHOW *****\n\n1.Seatwise reservation details\n";
	cout<<"2.Bus reservation details\n\nEnter choice:";
	cin>>ch1;
	clrscr();

	switch(ch1)
	{
	case 1:
	cout<<"Enter Bus no.:";
	cin>>busn;
	cout<<"Enter seat no.:";
	cin>>seat;
	cout<<"\n\tBus no.:"<<busn;
	cout<<"\n\tDriver's name:"<<driver;
	cout<<"\n\tSeat no.:"<<seat;
	cout<<"\n\tPassenger name:"<<pas_name;
	cout<<"\n\tFrom:Kolhapur"<<"\t\t\t\t"<<"To:"<<to;
	cout<<"\n\tFare:Rs."<<fare;
	cout<<"\n\tDate:"<<date;
	cout<<"\n\tArrival time:"<<arrival<<"\t\t\t\t"<<"Departure time:"<<depart;
	break;

	case 2:
	while(z)
	{
	z>>busn>>driver>>to>>fare>>arrival>>depart>>date;
		if(z.eof()==0)
		{
		cout<<"\nBus no.:"<<busn;
		cout<<"\t\t\tDriver's name:"<<driver;
		cout<<"\nSeat no.:"<<seat;
		cout<<"\t\t\tPassenger name:"<<pas_name;
		cout<<"\nFrom:Kolhapur"<<"\t\t\t"<<"To:"<<to;
		cout<<"\nDate:"<<date;
		cout<<"\nArrival time:"<<arrival<<"\t\t"<<"Departure time:"<<depart;
		cout<<"\n\n********************************************************************************";
		}
	}
/*      for(s=0;s<32;s++)
	{
	}*/
	break;
	}
	z.close();
	getch();
	}

	void enquiry()
	{
	clrscr();
	z.open("data.txt",ios::in);
	cout<<"\n\n\t\t\t***** BUS RESERVATION SYSTEM *****\n\n";
	cout<<"\t\t\t      *****  ENQUIRY  *****\n\n";
	cout<<"\t\t\t\tSource:Kolhapur\n";
	cout<<"\n--------------------------------------------------------------------------------";
	cout<<"Bus no.\t   Dest.        Fare\t Date\t\tArr time\tDept time";
	cout<<"\n--------------------------------------------------------------------------------";

	while(z)
	{
	z>>busn>>driver>>to>>fare>>arrival>>depart>>date;
		if(z.eof()==0)
		{
		cout<<busn<<"\t   "<<to<<"  \t"<<fare<<"\t"<<date<<"\t"<<"  "<<arrival<<"\t\t"<<"  "<<depart<<endl;
		}
	}
	z.close();
	getch();
	}
};

/*void pass()
{
int i=0;
char p[6];
clrscr();

cout<<"\n\n\n\n\n\t\t\tEnter password:";
	for(i=0;i<6;i++)
	{
	p[i]=getch();
	cout<<"*";
	}
	p[i]='\0';

	if(strcmp("smokie",p)==0)
	{
	getch();
	cout<<"\n\n\n\t\t\tPassword correct";
	cout<<"\n\n\t\t\tPress Any To Continue.....";
	getch();
	}
	else
	{
	getch();
	cout<<"\n\n\n\t\t\tIncorrect password";
	getch();
	exit(0);
	}
}*/

void main()
{
clrscr();
bus b;
int w,gd=DETECT,gm,ch;
/*initgraph(&gd,&gm,"c:\\tc\\bgi");
setbkcolor(BLUE);*/

//pass();

do
{
clrscr();
cout<<"\n\n\t\t\t***** BUS RESERVATION SYSTEM *****\n\n\n\t\t\t\t-*-*-*-MENU-*-*-*-\n\n\t\t\t\t1.Install\n\t\t\t\t2.Booking\n\t\t\t\t3.Update\n\t\t\t\t4.Show\n\t\t\t\t5.Cancellation\n\t\t\t\t6.Enquiry\n\t\t\t\t7.Exit\nEnter choice:";
cin>>ch;

switch(ch)
{
	case 1: b.install();
		break;
/*	case 2: b.booking();
		break;
	case 3: b.update();
		break;*/
	case 4: b.show();
		break;
/*	case 5: b.cancel();
		break;*/
	case 6: b.enquiry();
		break;
	case 7: exit(0);
}
}while(ch!=7);
getch();
}


Was This Post Helpful? 0
  • +
  • -

#8 jimblumberg  Icon User is offline

  • member icon


Reputation: 4098
  • View blog
  • Posts: 12,681
  • Joined: 25-December 09

Re: Problem with the update and booking section

Posted 25 March 2011 - 08:01 AM

First you should move your class member function implementations out of your class definition.
class bus
{
   int busn;
   int s;
   int fare;
   int i;
   int seat;
   char driver[10];
   char arrival[5];
   char depart[5];
   char to[10];
   char date[10];
   char pas_name[20];

   fstream x;
   fstream z;

public:
	void install();
        // The rest of your public members here.
};

void bus::install()
{
	clrscr();
	z.open("data.txt",ios::app);
	cout<<"\n\n\t\t\t***** BUS RESERVATION SYSTEM *****\n\n";
	cout<<"\t\t\t*******INSTALL*******\n\n";
	for(i=0;i<1;i++)
	{
	cout<<"\n\tSource:Kolhapur";
	cout<<"\n\tEnter bus no: ";
	cin>>busn;
	cout<<"\n\tEnter driver's name: ";
	cin>>driver;
	cout<<"\n\tEnter destination:";
	cin>>to;
	cout<<"\n\tEnter fares:";
	cin>>fare;
	cout<<"\n\tEnter arrival time: ";
	cin>>arrival;
	cout<<"\n\tEnter departure time: ";
	cin>>depart;
	cout<<"\n\tEnter date (dd/mm/yy):";
	cin>>date;
	z<<busn<<"\t"<<driver<<"\t"<<to<<"\t"<<fare<<"\t"<<arrival<<"t"<<depart<<"\t"<<date<<endl;
	}
	z.close();
	getch();
}

// Add the rest of your member functions here.




And after you clean up your class definition and implementation your main function should be defined as returning an int.

I would also highly suggest that you investigate the possibility of changing your compiler for an up to date standard compliant compiler. Your compiler is decades old and was last updated before the C++ standard was ratified and is therefore not standard compliant. And you will have problems running this compiler with the most modern operating systems. Also even if you stick with Turbo-C limit or preferably eliminate the use of non-standard header files and their functions such as conio.h, dos.h and graphics.h. These header files contain functions that were designed to work only on 16 bit DOS (DOS == Pre-Windows) and Microsoft is dropping support for 16 bit programs in their new operating systems. This means that you should not use functions like clrscr(), getch(), initgraph(), etc... If you continue to use this compiler and non-standard headers you will find that many people will take one look at your code and run for the hills.


Jim
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1