Console Application 3
Console Application 3
//
#include<fstream>
#include<iostream>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
#include<cstdio>
#include<process.h>
#include<dos.h>
#include<stdio.h>
#include<cstdlib>
#include <random>
{ public:
int planeno;
int pl;
plane() // constructor
planeno = 0;
strcpy(time," ");
cin>>ws;
cin.getline(planename,50);
cin.getline(start,50);
cin.getline(destination,50);
cout<<"\n\n\t\tDistance : ";
cin>>distance;
cin>>ws;
cin.getline(date,50);
cout<<"\n\n\t\tTime : ";
cin.getline(time,50);
cout<<endl;
cout<<endl;
}
void modify() // used to modify any record
puts(planename);
puts(start);
puts(destination);
cout << "\n\n\t\tNew Plane No. :(Enter -1 to retain old one) ";
cout << "\n\t\tNew Plane Name. :(Press '.' to retain old one) ";
cin>>ws;
cin>>nam;
cout << "\n\t\tNew Boarding Pt. :(press '.' to retain old ome) ";
cin>>st;
cout << "\n\tNew Destination. :(press '.' to retain old one) ";
cin>>dest;
cin>>di;
cin>>ws;
gets(da);
gets(ti);
if (pl != -1)
planeno = pl;
if (strcmp(nam, ".") != 0)
strcpy(planename, nam);
if (strcmp(st, ".") != 0)
strcpy(start, st);
if (strcmp(dest, ".") != 0)
strcpy(destination, dest);
if(di!=-1)
distance=di;
if(strcmp(da,".")!=0)
strcpy(date,da);
if(strcmp(ti,".")!=0)
strcpy(time,ti);
{ public:
char name[50];
char psource[50],pdestination[50];
float fare;
resno=rand()+(350 - 20 + 1);
cin>>ws;
gets(name);
cout<<"\n\tSource : ";
cin>>ws;
gets(psource);
cout<<"\n\tDestination : ";
gets(pdestination);
int rough_fare=price(psource,pdestination);
fare=rough_fare+(rough_fare*0.05);
cout<<"\n\tPrice : "<<rough_fare<<endl;
cout<<"\tGST(5%) :+ "<<(rough_fare*0.05)<<endl;
cout<<"\n\tDate : ";rdate(psource,pdestination);
cout<<"\n\tTime : ";rtime(psource,pdestination);
ifstream fin;
fin.open("plane.dat",ios::in|ios::binary);
plane p2;
char adate[50];
while(!fin.eof())
fin.read((char*)&p2,sizeof(p2));
if(strcmp(p2.start,tsource)==0&&strcmp(p2.destination,tdestination)==0)
strcpy(adate,p2.date);
} fin.close();
cout<<adate;
ifstream fin;
fin.open("plane.dat",ios::in|ios::binary);
plane p2;
char atime[50];
while(!fin.eof())
fin.read((char*)&p2,sizeof(p2));
if(strcmp(p2.start,tsource)==0&&strcmp(p2.destination,tdestination)==0)
strcpy(atime,p2.time);
} fin.close();
cout<<atime;
ofstream fout;
if (!fout)
char ch = 'y';
system("cls");
p.getdata();
fout.write((char*)& p, sizeof(p));
fout.close();
ifstream fin;
if (!fin)
cout<<" Plane Number \t\t Plane Name \t\t Source \t\t Destination \t\t Date \t\t Time \n\n
";
cout<<"----------------------------------------------------------------------------------------------------------------------------
------"<<endl;
p.putdata();
getch();
fin.close();
ofstream fout;
if (!fout)
char ch = 'y';
system("cls");
p.getdata();
fout.write((char*)& p, sizeof(p));
fout.close();
ifstream fo;
if (!fo)
cout << "\n\n\n\t\tEnter the Plane No. whose details you want to see . : ";
int ps;
while (!fo.eof())
fo.read((char*)& p, sizeof(p));
if (p.planeno == ps)
p.putdata();
_getch();
break;
else
fo.close();
fstream fio;
cout << "\n\n\tEnter the Plane no. whose record is to be modified \n ";
pos = fio.tellg();
fio.read((char*)& p, sizeof(p));
if (p.planeno == pno)
p.modify();
fio.seekg(pos);
fio.write((char*)& p, sizeof(p));
found = 't';
break;
if (found == 'f')
fio.seekg(0);
fio.close();
ifstream fio;
ofstream file;
cout << "\n\n\t\tEnter the Plane No. whose record is to be deleted \n ";
while (!fio.eof())
fio.read((char*)& p, sizeof(p));
if (p.planeno == pn)
p.putdata();
found = 't';
cout << "\n\n\tAre you sure you want to delete this record? (y/n).. ";
if (confirm == 'n')
file.write((char*)& p, sizeof(p));
else
file.write((char*)& p, sizeof(p));
if (found == 'f')
fio.close();
file.close();
remove("plane.dat");
rename("temp.dat", "plane.dat");
char a;
cin >> a;
if (a == 'y' | a == 'Y')
display();
ofstream fo;
fo.open("ticket.dat", ios::out | ios::binary);
if (!fo)
char b = 'y';
t.get();
fo.write((char*)& t, sizeof(t));
cin >> b;
fo.close();
ifstream fin;
fin.open("plane.dat",ios::in|ios::binary);
if(!fin)
cout<<"File Is empty"<<endl;
exit(0);
} plane p1;
int fare;
int tdistance;
while(!fin.eof())
{ fin.read((char*)&p1,sizeof(p1));
if(strcmp(p1.start,tsource)==0&&strcmp(p1.destination,tdestination)==0)
tdistance=p1.distance;
}
if(tdistance<=200)
fare=20*tdistance;
else if(tdistance>200&&tdistance<=500)
fare=18*tdistance;
else if(tdistance>500&&tdistance<=1000)
fare=15*tdistance;
else if(tdistance>1000&&tdistance<=2500)
fare=14*tdistance;
else if(tdistance>2500&&tdistance<=5000)
fare=12*tdistance;
else if(tdistance>5000&&tdistance<=10000)
fare=10*tdistance;
else
fare=8*tdistance;
int c;
cin>>c;
int discount=0;
switch(c)
case 1: discount=fare*0.1;
break;
case 2: discount=fare*0.2;
break;
break;
case 4:
break;
default:
cout<<"Please Enter valid option from given categories only"<<endl;
return (fare-discount);
fin.close();
ifstream fin;
ofstream fo;
if (!fin)
if (!fo)
cout << "\n\n\t\tEnter the Reservation No. which you want to cancel ";
int rn;
while (!fin.eof())
fin.read((char*)& t, sizeof(t));
if (t.resno == rn)
t.put();
cout << "\n\n\tDo you really want to cancel your ticket ?(y/n)";
char r;
cin >> r;
if (r == 'y' || r == 'Y')
{
cout << "\n\n\t\t\tYour Ticket has been cancelled ";
else
fo.write((char*)& t, sizeof(t));
break;
else
fo.write((char*)& t, sizeof(t));
remove("ticket.dat");
rename("temp.dat", "ticket.dat");
fin.close();
fo.close();
ifstream fin;
if (!fin)
cout << "Enter the Reservation No. of Ticket you Want to see : ";
int res;
int a = 0;
while (!fin.eof())
{
fin.read((char*)& t, sizeof(t));
if (t.resno == res)
a = 1;
break;
else
a = 4;
if (a == 1)
t.put();
_getch();
if (a == 4)
fin.close();
int main()
{}
system("cls");
int den;
system("cls");
if (den == 0)
exit(0);
else if (den == 2)
char ch = 'y';
system("cls");
cout << "\n\n\n\n\n\n";
cout <<
"*************************************************************************";
cout <<
"*************************************************************************";
int choice;
system("cls");
switch (choice)
case 1: display();
break;
case 2: reservation();
break;
case 3: dispreserve();
break;
case 4: cancellation();
break;
exit(0);
break;
else if (den == 1)
int k = 0;
while (k < 4)
system("cls");
strcpy(p, "inaeroplane");
pass[0] = _getch();
pass[1] = _getch();
pass[2] = _getch();
pass[3] =_getch();
pass[4] = _getch();
pass[5] = _getch();
pass[6] = _getch();
cout << "*";
pass[7] = _getch();
pass[8] = _getch();
pass[9] = _getch();
pass[10] = _getch();
pass[11] = '\0';
_getch();
if (strcmp(pass, p) == 0)
k = 4;
else
char g;
cin >> g;
if (g == 'y' | g == 'Y')
k++;
else
exit(0);
}
system("cls");
cout <<
"*************************************************************************";
cout <<
"*************************************************************************";
int choice1;
system("cls");
switch (choice1)
case 1: write();
break;
case 2: display();
break;
case 3: add();
break;
case 4: search();
break;
case 5: mod();
break;
case 6: del();
break;
exit(0);
break;
_getch();
// 3. Use the Output window to see build output and other messages
// 4. Use the Error List window to view errors
// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add
existing code files to the project
// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file