PLEASE HELP ME GUYS ! THIS IS VERY IMPORTANT This is my airline reservation prog
ID: 3626334 • Letter: P
Question
PLEASE HELP ME GUYS ! THIS IS VERY IMPORTANT
This is my airline reservation prog. that was modified by someone else.That person introduced files in the program to create and display simple profile info. for passengers and their booked flights.(which is my goal)
Now he used stuff such as "itoa" AND "outfile.open(str.c_str()); " (character casting),
"memset", dynamic arrays etc. PLZ CAN ANY OF U SEE WHETHER THE PROGRAM BELOW CAN BE DONE IN AN EASIER WAY (IM A NEWBIE TO FILES AND NOT SUCH AN EXPERT AT C++ :( . IF U HELP, I WILL FOREVER BE THANKFUL TO U!)
THIS IS THE MODIFIED VERSION WITH FILES
#include
using namespace std;
string IntToString(int intValue) {
char *myBuff;
string strRetVal;
// Create a new char array
myBuff = new char[100];
// Set it to empty
memset(myBuff,'',100);
// Convert to string
itoa(intValue,myBuff,10);
// Copy the buffer into the string object
strRetVal=myBuff;
// Delete the buffer
delete[] myBuff;
return(strRetVal);
}
void making_profile(int profile_counter,int password, string dest,int row,int column)
{ifstream infile;
ofstream outfile;
string str=IntToString(profile_counter)+".txt";
outfile.open(str.c_str());
outfile}
void open_profile(int profile_number,int password)
{ifstream infile;
string line;
string stri=IntToString(profile_number)+".txt";
infile.open(stri.c_str());
string str=IntToString(password);
char choise;
if(!infile)
cout<<"profile not found"<
else
{
getline(infile,line);
if(line == str)
{
cout<<"Do you want to print your profile information">choise;
if(choise =='y' || choise =='Y')
{
while (!infile.eof())
{
getline(infile,line);
cout<}
}
}
else
cout<<"wrong credinatals"<}
infile.close();
}
char add_profile(int profile_number,int password,string dest,int row,int column)
{
fstream infile;
string stri=IntToString(profile_number)+".txt";
infile.open(stri.c_str());
string str=IntToString(password);
string line;
if(!infile)
cout<<"profile nou found"<
else
{
getline(infile,line);
if(line==str)
{
infile.seekp (0, ios::end);
infile<<"you booked a seat to "}
else
{
cout<<"wrong credinatals"}
}
infile.close();
}
void main()
{
char Egypt[30][10],US[30][10],UK[30][10];
char choise='y';
int choice;
int row;
int column;
int password;
int destinationChoice;
char name[10];
int role;
static int profile_counter=1;
int profile_password;
int profile_number;
char check , che;
for(int i=0;i<30;i++) //Initializing all seats to EMPTY
{
for(int j=0;j<10;j++)
{Egypt[i][j]='E';
US[i][j]='E';
UK[i][j]='E';}
}
while(choise=='y')
{
cout<<"Press 1 for ADMIN's menu or 2 for USER's menu ";
cin>>role;
cout<{
if(role==1)
{
{while(choise=='y')
{
cout<<" "WELCOME TO ADMIN'S MENU "{
cout<<"Please enter the PASSWORD">password;
if(password==10)
{
cout<<" 1 to see all the seats "else
{
cout<<"YOU HAVE ENTERED AN INVALID PASSWORD"}
cin>>choice;
cout{case 1:
{
do
{
cout<<"Enter destination 1 to Egypt 2 to US 3 to UK 4 to back menu">destinationChoice;
switch(destinationChoice)
{
case 1:
for(int m=0;m<30;m++)
{
for(int n=0; n<10; n++)
{cout
case 2:
for(int m=0;m<30;m++)
{
for(int n=0; n<10; n++)
{
coutbreak;
case 3:
for(int m=0;m<30;m++)
{
for(int n=0; n<10; n++)
{
cout}}while(destinationChoice<4 && (destinationChoice>0));}
break;
case 2:
{ do
{
cout<<"Enter destination 1 to Egypt 2 to US 3 to UK 4 to back menu">destinationChoice;
switch(destinationChoice)
{
case 1:
for(int o=0; o<30;o++)
{
for(int p=0;p<10;p++)
{
if(Egypt[o][p]=='B')
{cout<}
coutcase 2:
for(int o=0; o<30;o++)
{
for(int p=0;p<10;p++)
{
if(US[o][p]=='B')
{cout<}
coutcase 3:
for(int o=0; o<30;o++)
{
for(int p=0;p<10;p++)
{
if(UK[o][p]=='B')
{cout<}
cout<}}while(destinationChoice<4 && destinationChoice>0);}
break;
case 3:
do
{
cout<<"Enter destination 1 to Egypt 2 to US 3 to UK 4 to back menu">destinationChoice;
switch(destinationChoice)
{
case 1:
{for(int q=0;q<30;q++)
for(int l=0;l<10;l++)
{if(Egypt[q][l]=='E')
{coutcase 2:
{for(int q=0;q<30;q++)
for(int l=0;l<10;l++)
{if(US[q][l]=='E')
{coutcase 3:
{for(int q=0;q<30;q++)
for(int l=0;l<10;l++)
{if(UK[q][l]=='E')
{cout}while(destinationChoice<4 &&destinationChoice>0);
break;
case 4:
cout<<"Enter destination 1 to Egypt 2 to US 3 to UK ">destinationChoice;
cout<<"Please enter the row of seat ";
cin>>row;
row=row-1;
cout<<"Please enter the column of seat ";
cin>>column;
column=column-1;
switch(destinationChoice)
{
case 1:
if(Egypt[row][column]=='B')
{Egypt[row][column]='E';
cout<<"The reserved seat is changed to EMPTY"{cout<<"The given seat is already EMPTY"
case 2:
if(US[row][column]=='B')
{US[row][column]='E';
cout<<"The reserved seat is changed to EMPTY"{cout<<"The given seat is already EMPTY"
case 3:
if(UK[row][column]=='B')
{UK[row][column]='E';
cout<<"The reserved seat is changed to EMPTY"{cout<<"The given seat is already EMPTY"}
cout<<"Do you want to repeat the menu press Y or N ";
cin>>choise;}}}}
if(role==2)
{
char choise='y';
while(choise=='y')
{
cout<<" "WELCOME TO PIA HELP LINE SIR" ">che;
if(che =='y' || che=='Y')
{
cout<<"enter your profile number ">profile_number;
cout<<"please enter your passowrd">profile_password;
open_profile(profile_number,profile_password);
}
else
{
cout<<"Please enter the name of the country for which you want to fly (Egypt,US,UK) ">name;
cout<<" Now press 6 for viewing all the seats in that flight ">choice;
coutswitch(choice)
{
case 6:
{if(strcmp(name,"Egypt")==0)
{
for(m=0;m<30;m++)
{
for(int n=0; n<10; n++)
{
cout{
for(m=0;m<30;m++)
{
for(int n=0; n<10; n++)
{
cout{
for(m=0;m<30;m++)
{
for(int n=0; n<10; n++)
{
coutcout<<"Invalid destination"
case 7:
{cout<<"PLease enter row number ";
cin>>row;
row=row-1;
cout<<"Please enter he column number ";
cin>>column;
column=column-1;
cout{
if(Egypt[row][column]=='B')
{cout<<"Sorry the seat is already BOOKED"}
else
{
Egypt[row][column]='B';
cout<<"do You have a profile in here ">check;
if(check=='y')
{
check= add_profile(profile_number,profile_password,"Egypt",row,column);
if(check=='y')
open_profile(profile_number,profile_password);
}
else
{
cout<<"you have a profile number ">profile_password;
making_profile(profile_counter,profile_password,"Egypt",row,column);
}
cout<<"Your seat is BOOKED enjoy the flight"<
}
}
else if(strcmp(name,"US")==0)
{
if(US[row][column]=='B')
{cout<<"Sorry the seat is already BOOKED"}
else
{US[row][column]='B';
cout<<"do You have a profile in here ">check;
if(check=='y')
{
cout<<"enter your profile number ">profile_number;
cout<<"please enter your passowrd">profile_password;
check= add_profile(profile_number,profile_password,"US",row,column);
if(check=='y')
open_profile(profile_number,profile_password);
}
else
{
cout<<"you have a profile number ">profile_password;
making_profile(profile_counter,profile_password,"Us",row,column);
}
cout<<"Your seat is BOOKED enjoy the flight"<
}
else if(strcmp(name,"UK")==0)
{
if(UK[row][column]=='B')
{cout<<"Sorry the seat is already BOOKED"}
else
{UK[row][column]='B';
cout<<"do You have a profile in here ">check;
if(check=='y')
{
cout<<"enter your profile number ">profile_number;
cout<<"please enter your passowrd">profile_password;
check= add_profile(profile_number,profile_password,"UK",row,column);
if(check=='y')
open_profile(profile_number,profile_password);
}
else
{
cout<<"you have a profile number ">profile_password;
making_profile(profile_counter,profile_password,"UK",row,column);
}
cout<<"Your seat is BOOKED enjoy the flight"<}
else
cout<<"Invalid destination"}}
profile_counter++;
cout<<"Do you want to repeat the menu press Y or N ";
cin>>choise;
}
}
cout<<"Do you want to repeat this program press Y or N ";
cin>>choise;
}
}
}
}
Explanation / Answer
I m removing this question!
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.