Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

NEED A REPORT OF THIS FOLLOWING CODE, the requirements of the report are mentioned in the picture kindly elaborate nicely #include #include #include using namespace

NEED A REPORT OF THIS FOLLOWING CODE, the requirements of the report are mentioned in the picture kindly elaborate nicely
#include
#include
#include
using namespace std;
int glob=0; //global variables
int global=10;
class d_booking //class for domestic booking
{
protected:
int pnr;
char f_d[10],toja[7],tojd[7]; //protected members
long int doj;
int choice,src,dest;
public://public member functions
void d_pnr()
{
glob++; // increment variable
pnr=glob;
}
int j_detail() // function declaration and definition for domestic journey
{
cout
cin >> doj;
cout
cout
cin >> src;
cout
cin >> dest;
if((src==1 && dest==2) || (src==2 && dest==1))//condition
{
cout
cout
cout
cout
cout
}
else if((src==1 && dest==3) || (src==3 && dest==1))//condition
{
cout
cout
cout
cout
cout
}
else if((src==1 && dest==4) || (src==4 && dest==1))//condition
{
cout
cout
cout
cout
cout
}
else if((src==2 && dest==3) || (src==3 && dest==2))//condition
{
cout
cout
cout
cout
cout
}
else if((src==2 && dest==4) || (src==4 && dest==2))//condition
{
cout
cout
cout
cout
cout
}
else if((src==3 && dest==4) || (src==4 && dest==3))//condition
{
cout
cout
cout
cout
cout
}
else if(src==dest)//condition
{
cout
return j_detail();
}
else
{
cout
return j_detail();
}
}
int select_flight() //function declaration and definition for selecting flight
{ cout
cin >> choice;
switch(choice) // switch case
{
case 1://condition
cout
cout
strcpy(f_d,"Qantas");//copy to string
cout
cout
strcpy(tojd,"8:00"); //copy to string
strcpy(toja,"11:05");// copy to string
break;
case 2://condition
cout
cout
strcpy(f_d,"Fly Dubai");//copy to string
cout
cout
strcpy(tojd,"14:00");//copy to string
strcpy(toja,"17:05");//copy to string
break;
case 3://condition
cout
cout
strcpy(f_d,"Go Air");//copy to string
cout
cout
strcpy(tojd,"19:00");//copy to string
strcpy(toja,"22:05");//copy to string
break;
default://condition
cout
return select_flight();
}
}
};
class i_booking//class for international booking
{
protected://protected members
int pnri;
char f_i[10],tojai[7],tojdi[7];
long int doji;
int srci,desti,choicei;
public://public member functions
void i_pnr()
{
global++;//increment variable
pnri=global;
}
//brought to you by code-projects.org
int j_detaili()// function declaration and definition for journey details
{
cout
cin >> doji;
cout
cout
cin >> srci;
cout
cin >> desti;
cout
if((srci==1 && desti==3) || (srci==3 && desti==1))//condition
{
cout
cout
cout
cout
}
else if((srci==1 && desti==4) || (srci==4 && desti==1))//condition
{
cout
cout
cout
cout
}
else if((srci==1 && desti==5) || (srci==5 || desti==1))//condition
{
cout
cout
cout
cout
}
else if((srci==2 && desti==3) || (srci==3 && desti==2))//condition
{
cout
cout
cout
cout
}
else if((srci==2 && desti==4) || (srci==4 && desti==2))//condition
{
cout
cout
cout
cout
else if(srci==2 && desti==5 || (srci==5 && desti==2))//condition
{
cout
cout
cout
cout
}
else if(srci==desti)//condition
{
cout
return j_detaili();
}
else//condition
{
cout
return j_detaili();
}
}
int select_flighti()//function declaration and definition for selecting flight
{
cout
cin >> choicei;
switch(choicei)//switch case
{
case 1://condition
cout
cout
strcpy(f_i,"Vistara");//copy to string
cout
cout
strcpy(tojdi,"10:00");//copy to string
strcpy(tojai,"14:05");//copy to string
break;
case 2://condition
cout
cout
strcpy(f_i,"Fly Dubai");//copy to string
cout
cout
strcpy(tojdi,"14:00");//copy to string
strcpy(tojai,"18:05");//copy to string
break;
case 3://condition
cout
cout
strcpy(f_i,"Emirates");//copy to string
cout
cout
strcpy(tojdi,"18:00");//copy to string
strcpy(tojai,"22:05");//copy to string
break;
default://condition
cout
return select_flighti();
}
}
};
class passenger: public d_booking,public i_booking//class passenger publicly inherited from class d_booking and i_booking
{
protected://protected members
char f_name[20],l_name[20],email[50];
int age,gender;
long int c_no;
public://public member functions
void p_detail(int x)//function declaration and definition
{ if(x==1)//if else for domestic and international booking selection
{ j_detail();//function call
select_flight();//function call
}
else
{ j_detaili();//function call1353
select_flighti();//function call
}
cout
cout
cin >> f_name;
cout
cin >> l_name;
}
int gender_check()//to check gender input as valid
{
cout
cin >> gender;
if(gender>2)//condition
{
cout
return gender_check();//function call
}
}
void more_details()//to take more details of the passenger
{
cout
cin >> age;
cout
cin >> email;
cout
cin >> c_no;
cout
cout
cout
cout
cout
cout
}
int getpnr()//function to get pnr for domestic booking
{
return pnr;
}
int getpnri()//function to get pnr for international booking
{
return pnri;
}
void disp()//function to display details for domestic booking
{
cout
cout
cout
cout
cout
cout
}
void dispi()//function to display details for international booking
{
cout
cout
cout
cout
cout
cout
}
};
class payment//class for payment
{
protected://protected members
long
int choice1,bank,card,date,cvv,user_id;
char password[10];
public://public members functions
void pay_detail()//function declaration and definition for payment method
{ cout
cout
cout
cin >> choice1;
switch(choice1)//switch case
{
case 1://condition
cout
cin >> card;
cout
cin >> date;
cout
cin >> cvv;
cout
break;
case 2://condition
cout
cin >> card;
cout
cin >> date;
cout
cin >> password;
cout
break;
case 3://condition
cout
cout
cin >> bank;
cout
cout
cin >> user_id;
cout
cin >> password;
cout
break;
default://condition
cout
return pay_detail();
}
}
};
void createfile(passenger p)//file creation for domestic booking
{ ofstream fin("domestic.txt",ios::binary|ios::app);
fin.write((char*)&p,sizeof(p));//writing to file
fin.close();//closing file
}
void cancelticket(int x)//function to cancel ticket
{ passenger p;
int f=0;
ifstream fout("domestic.txt",ios::binary|ios::app);//for reading file
ofstream fin("domestic1.txt",ios::binary|ios::app);//for writing to a new file
fout.read((char *)&p,sizeof(p));//reading file
while(fout)
{
if(p.getpnr()!=x)//checking pnr
fin.write((char *)&p,sizeof(p));//writing to file
else
{
p.disp();//display details
cout
f++;//incrementing f if pnr found
}
fout.read((char *)&p,sizeof(p));//reading another record from file
}
if(f==0)//if f==0,pnr not found
cout
fout.close();//closing file
fin.close();//closing file
remove("domestic.txt");//deleting old file
rename("domestic1.txt","domestic.txt");//renaming new file
}
void checkticket(int x)//function to check pnr or ticket
{ passenger p;
int f=0;
ifstream fout("domestic.txt",ios::binary);//opening file
fout.read((char *)&p,sizeof(p));//reading file
while(fout)
{
if(p.getpnr()==x)//checking pnr
{p.disp();//display details
cout
f++;//incrementing f if onr found
break;
}
fout.read((char *)&p,sizeof(p));//reading another record from the same file
}
fout.close();//closing file
if(f==0)//if f==0, pnr not found
cout
}
void createfilei(passenger p)//opening a file for international booking
{ ofstream fin("international.txt",ios::binary|ios::app);
fin.write((char*)&p,sizeof(p));//writing to file
fin.close();//closing file
}
void cancelticketi(int x)//function to cancel ticket
{ passenger p;
int f=0;
ifstream fout("international.txt",ios::binary|ios::app);//opening file
ofstream fin("international1.txt",ios::binary|ios::app);//writing to a new file
fout.read((char *)&p,sizeof(p));//reading old file
while(fout)
{
if(p.getpnri()!=x)//checking pnr
fin.write((char *)&p,sizeof(p));//writing to new file;
else
{
p.dispi();//display details
cout
f++;//incrementing f if pnr found
}
fout.read((char *)&p,sizeof(p));//reading another record from old file
}
if(f==0)//if f==0,pnr not found
cout
fout.close();//closing file
fin.close();//closing file
remove("international.txt");//deleting old file
rename("international1.txt","international.txt");//renaming new file
}
void checkticketi(int x)//function to check pnr or ticket
{ passenger p;
int f=0;
ifstream fout("international.txt",ios::binary);//opening file
fout.read((char *)&p,sizeof(p));//reading file
while(fout)
{
if(p.getpnri()==x)//checking pnr
{p.dispi();//display details
cout
f++;//incrementing f if pnr found
break;
}
fout.read((char *)&p,sizeof(p));//reading another record from the file
}
fout.close();//closing file
if(f==0)//if f==0, pnr not found
cout
}
int main()//main function
{
class d_booking d1;//object for class d_booking
class i_booking i1;//object for class i_booking
class passenger p1;//object for class passenger
class payment p2;//object for class payment
int ch,ch1,n;//integer variables
char input;//character variables
do//do while loop
{
system("CLS");
cout
cout ";
cout
cout ";
cout
cout
cin >> ch;
switch(ch)//witch case
{
case 1://condition
system("CLS");
cout
cout
cin >> ch1;
switch(ch1)//inner switch case
{
case 1://for booking domestic ticket
p1.d_pnr();
p1.p_detail(1);//function calls
p1.gender_check();
p1.more_details();
p2.pay_detail();
p1.disp();
createfile(p1);//call to create file
break;
case 2: //for booking international ticket
p1.p_detail(2);//function calls
p1.i_pnr();
p1.gender_check();
p1.more_details();
p2.pay_detail();
p1.dispi();
createfilei(p1);//call to create file
break;
default://wrong input
cout
return main();
}
break;
case 2:
//for canceling ticket
system("CLS");
cout
cout
cin >> ch1;
if(ch1==1)
{
cout
cin>>n;
cancelticket(n);//function call for domestic booking cancellation
}
else if(ch1==2)
{ cout
cin>>n;
cancelticketi(n);//function call for international cancellation
}
else
{
cout
return main();
}
break;
case 3://for displaying booked ticket details
system("CLS");
cout
cout
cin >> ch1;
if(ch1==1)
{cout
cin>>n;
checkticket(n);}//function call to display domestic ticket details
else if(ch1==2)
{ cout
cin>>n;
checkticketi(n);//function call to display domestic ticket details
}
else
{
cout
return main();
}
break;
case 4:
system("CLS");
cout
return 0;
default://for wrong input
cout
return main();
}
cout
cin >> input;
}while(input=='Y' || input=='y');//condition for do while loop
return 0;
}
image text in transcribed
Submission Requirements Submit a project report for your C++ coding project. Your report should consist of the following elements: . . . Title: This should be concise and informative. Table of Contents. Introduction: This should describe the relevant study areas covered in your project and explain the objectives. Main Menu Flowchart: Method outline of the method included. Program Flowchart: Discuss the program flow. Source Code: Make sure your source code is well commented. Program Output: Attach pictures of your outputs Description of Program - Stepwise: Describe in detail a sample run of the program, the sequence of events, functions and their working. Discussion/improvements: Comment critically on any difficulties encountered. Suggest any further improvements that you could have made. References: Mention any help material used

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Focus On Geodatabases In ArcGIS Pro

Authors: David W. Allen

1st Edition

1589484452, 978-1589484450

More Books

Students also viewed these Databases questions

Question

What is augmented reality? How can it be used?

Answered: 1 week ago

Question

Identify and control your anxieties

Answered: 1 week ago

Question

Understanding and Addressing Anxiety

Answered: 1 week ago