#include<iostream.h>
#include<string.h>
#include<conio.h>
#include<math.h>
#include<stdio.h>
class station
{
protected:
int password;
char *name;
int trainno;
char **trainname;
int *atimeh;
int *atimem;
int *dtimeh;
int *dtimem;
int *stimeh;
int *stimem;
public:
void passwd()
{
cout<<"enter the initial password";
cin>>password;
}
void cpasswd();
void getbasicdata();
void timetable();
};
void station::cpasswd()
{
int o,n,rn;
cout<<"enter the old password";
cin>>o;
if(o==password)
{
cout<<"enter new password";
cin>>n;
cout<<"enter new password again";
cin>>rn;
if(n==rn)
{
password=n;
cout<<"possword successfully changed"<<"\n";
}
else
{
cout<<"you not enter the same password\n";
}
}
else
{
cout<<"you enter wrong password\n";
}
}
void station::getbasicdata()
{
int p;
cout<<"enter password";
cin>>p;
if(p==password)
{
name=new char[20];
cout<<"enter the station name";
gets(name);
//cin.getline(name,20);
cout<<"enter the no, of trains going through the station";
cin>>trainno;
//break;
trainname=new char*[trainno];
atimeh=new int[trainno];
atimem=new int[trainno];
dtimeh=new int[trainno];
dtimem=new int[trainno];
stimeh=new int[trainno];
stimem=new int[trainno];
for(int i=0;i<trainno;i++)
{
trainname[i]=new char[30];
cout<<"ENTER THE TRAIN NAME";
gets(trainname[i]);
cout<<"ENTER THE TRAIN ARRIVAL TIME IN HOUR AND MINUTES";
cin>>atimeh[i]>>atimem[i];
cout<<"ENTER THE TRAIN DEPARTURE TIME IN HOUR AND MINUTES";
cin>>dtimeh[i]>>dtimem[i];
if(dtimeh[i]==0)
{
stimeh[i]=24-atimeh[i];
}
else
{
stimeh[i]=dtimeh[i]-atimeh[i];
}
if(dtimem[i]>=atimem[i])
{
stimem[i]=dtimem[i]-atimem[i];
}
else
{
stimem[i]=dtimem[i]-atimem[i]+60;
stimeh[i]=stimeh[i]-1;
}
}
}
}
void station::timetable()
{
clrscr();
cout<<"___________________________________________________________________\n";
int ww=strlen(name);
for(int qq=0;qq<((65-(18+ww))/2);qq++)
{
cout<<" ";
}
cout<<"THE TIME TABLE OF "<<name<<"\n";
cout<<"-------------------------------------------------------------------\n";
cout<<"NAME ARRIVAL TIME DEPARTURE TIME SPENT TIME\n";
for(int i=0;i<trainno;i++)
{
cout<<trainname[i];
ww=strlen(trainname[i]);
for(qq=0;qq<(16-ww);qq++)
{
cout<<" ";
}
if(atimeh[i]<10)
{
cout<<" 0";
}
else
{
cout<<" ";
}
cout<<atimeh[i];
if(atimem[i]<10)
{
cout<<":0";
}
else
{
cout<<":";
}
cout<<atimem[i];
if(dtimeh[i]<10)
{
cout<<" 0";
}
else
{
cout<<" ";
}
cout<<dtimeh[i];
if(dtimem[i]<10)
{
cout<<":0";
}
else
{
cout<<":";
}
cout<<dtimem[i];
if(stimeh[i]<10)
{
cout<<" 0";
}
else
{
cout<<" ";
}
cout<<stimeh[i];
if(stimem[i]<10)
{
cout<<":0";
}
else
{
cout<<":";
}
cout<<stimem[i]<<"\n";
}
cout<<"-------------------------------------------------------------------\n";
}
void main()
{
station a;
a.passwd();
a.cpasswd();
a.getbasicdata();
a.timetable();
}
#include<string.h>
#include<conio.h>
#include<math.h>
#include<stdio.h>
class station
{
protected:
int password;
char *name;
int trainno;
char **trainname;
int *atimeh;
int *atimem;
int *dtimeh;
int *dtimem;
int *stimeh;
int *stimem;
public:
void passwd()
{
cout<<"enter the initial password";
cin>>password;
}
void cpasswd();
void getbasicdata();
void timetable();
};
void station::cpasswd()
{
int o,n,rn;
cout<<"enter the old password";
cin>>o;
if(o==password)
{
cout<<"enter new password";
cin>>n;
cout<<"enter new password again";
cin>>rn;
if(n==rn)
{
password=n;
cout<<"possword successfully changed"<<"\n";
}
else
{
cout<<"you not enter the same password\n";
}
}
else
{
cout<<"you enter wrong password\n";
}
}
void station::getbasicdata()
{
int p;
cout<<"enter password";
cin>>p;
if(p==password)
{
name=new char[20];
cout<<"enter the station name";
gets(name);
//cin.getline(name,20);
cout<<"enter the no, of trains going through the station";
cin>>trainno;
//break;
trainname=new char*[trainno];
atimeh=new int[trainno];
atimem=new int[trainno];
dtimeh=new int[trainno];
dtimem=new int[trainno];
stimeh=new int[trainno];
stimem=new int[trainno];
for(int i=0;i<trainno;i++)
{
trainname[i]=new char[30];
cout<<"ENTER THE TRAIN NAME";
gets(trainname[i]);
cout<<"ENTER THE TRAIN ARRIVAL TIME IN HOUR AND MINUTES";
cin>>atimeh[i]>>atimem[i];
cout<<"ENTER THE TRAIN DEPARTURE TIME IN HOUR AND MINUTES";
cin>>dtimeh[i]>>dtimem[i];
if(dtimeh[i]==0)
{
stimeh[i]=24-atimeh[i];
}
else
{
stimeh[i]=dtimeh[i]-atimeh[i];
}
if(dtimem[i]>=atimem[i])
{
stimem[i]=dtimem[i]-atimem[i];
}
else
{
stimem[i]=dtimem[i]-atimem[i]+60;
stimeh[i]=stimeh[i]-1;
}
}
}
}
void station::timetable()
{
clrscr();
cout<<"___________________________________________________________________\n";
int ww=strlen(name);
for(int qq=0;qq<((65-(18+ww))/2);qq++)
{
cout<<" ";
}
cout<<"THE TIME TABLE OF "<<name<<"\n";
cout<<"-------------------------------------------------------------------\n";
cout<<"NAME ARRIVAL TIME DEPARTURE TIME SPENT TIME\n";
for(int i=0;i<trainno;i++)
{
cout<<trainname[i];
ww=strlen(trainname[i]);
for(qq=0;qq<(16-ww);qq++)
{
cout<<" ";
}
if(atimeh[i]<10)
{
cout<<" 0";
}
else
{
cout<<" ";
}
cout<<atimeh[i];
if(atimem[i]<10)
{
cout<<":0";
}
else
{
cout<<":";
}
cout<<atimem[i];
if(dtimeh[i]<10)
{
cout<<" 0";
}
else
{
cout<<" ";
}
cout<<dtimeh[i];
if(dtimem[i]<10)
{
cout<<":0";
}
else
{
cout<<":";
}
cout<<dtimem[i];
if(stimeh[i]<10)
{
cout<<" 0";
}
else
{
cout<<" ";
}
cout<<stimeh[i];
if(stimem[i]<10)
{
cout<<":0";
}
else
{
cout<<":";
}
cout<<stimem[i]<<"\n";
}
cout<<"-------------------------------------------------------------------\n";
}
void main()
{
station a;
a.passwd();
a.cpasswd();
a.getbasicdata();
a.timetable();
}
for more code you can Visit http://codesofprogramming.blogspot.in/
No comments:
Post a Comment