PLZ HELP ME GUYS !!! Can u plz plz MODIFY THE FILES PORTION OF the program below
ID: 3626332 • Letter: P
Question
PLZ HELP ME GUYS !!!
Can u plz plz MODIFY THE FILES PORTION OF the program below so that it is understandable to A person like me who has just started studying files!! Basically the prog. maintains a simple profile regarding Airline registration using files.
(DO NOT USE CLASSES). I mean we have just studied the basics of writing and reading to a file. And if u think that a certain part of program needs to be removed because its too complex , remove and simplify it!
#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<outfile<<"you booked a seat to "<outfile<<"your location is in row "<outfile<outfile.close();
}
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"<cin>>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 "<infile<<"your location is in row "<return 'y';
}
else
{
cout<<"wrong credinatals"<return 'n';
}
}
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 "<for(int u=0;u<1;u++)
{
cout<<"Please enter the PASSWORD"<cin>>password;
if(password==10)
{
cout<<" 1 to see all the seats "<cout<<" 2 for seeing already BOOKED seats "<cout<<" 3 for seeing EMPTY seats "<cout<<" 4 for cancelling a BOOKED seat "<}
else
{
cout<<"YOU HAVE ENTERED AN INVALID PASSWORD"<break;
}
cin>>choice;
cout<switch(choice)
{case 1:
{
do
{
cout<<"Enter destination 1 to Egypt 2 to US 3 to UK 4 to back menu"<cin>>destinationChoice;
switch(destinationChoice)
{
case 1:
for(int m=0;m<30;m++)
{
for(int n=0; n<10; n++)
{cout<cout<break;
case 2:
for(int m=0;m<30;m++)
{
for(int n=0; n<10; n++)
{
cout<cout<}
break;
case 3:
for(int m=0;m<30;m++)
{
for(int n=0; n<10; n++)
{
cout<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"<cin>>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<}
cout<break;
case 2:
for(int o=0; o<30;o++)
{
for(int p=0;p<10;p++)
{
if(US[o][p]=='B')
{cout<}
cout<break;
case 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"<cin>>destinationChoice;
switch(destinationChoice)
{
case 1:
{for(int q=0;q<30;q++)
for(int l=0;l<10;l++)
{if(Egypt[q][l]=='E')
{cout<cout<break;
case 2:
{for(int q=0;q<30;q++)
for(int l=0;l<10;l++)
{if(US[q][l]=='E')
{cout<cout<break;
case 3:
{for(int q=0;q<30;q++)
for(int l=0;l<10;l++)
{if(UK[q][l]=='E')
{cout<cout<}
}while(destinationChoice<4 &&destinationChoice>0);
break;
case 4:
cout<<"Enter destination 1 to Egypt 2 to US 3 to UK "<cin>>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"<else
{cout<<"The given seat is already EMPTY"<break;
case 2:
if(US[row][column]=='B')
{US[row][column]='E';
cout<<"The reserved seat is changed to EMPTY"<else
{cout<<"The given seat is already EMPTY"<break;
case 3:
if(UK[row][column]=='B')
{UK[row][column]='E';
cout<<"The reserved seat is changed to EMPTY"<else
{cout<<"The given seat is already EMPTY"<break;}
}
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" "<cout<<"Do you have a profile you want see"<cin>>che;
if(che =='y' || che=='Y')
{
cout<<"enter your profile number "<cin>>profile_number;
cout<<"please enter your passowrd"<cin>>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) "<cin>>name;
cout<<" Now press 6 for viewing all the seats in that flight "<cout<<" Now press 7 for BOOKING a seat in that flight "<cin>>choice;
cout<int m;
switch(choice)
{
case 6:
{if(strcmp(name,"Egypt")==0)
{
for(m=0;m<30;m++)
{
for(int n=0; n<10; n++)
{
cout<cout<else if(strcmp(name,"US")==0)
{
for(m=0;m<30;m++)
{
for(int n=0; n<10; n++)
{
cout<cout<else if(strcmp(name,"UK")==0)
{
for(m=0;m<30;m++)
{
for(int n=0; n<10; n++)
{
cout<cout<else
cout<<"Invalid destination"<break;
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(strcmp(name,"Egypt")==0)
{
if(Egypt[row][column]=='B')
{cout<<"Sorry the seat is already BOOKED"<//Beep(20000,5000);
}
else
{
Egypt[row][column]='B';
cout<<"do You have a profile in here "<cin>>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 "<cin>>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"<//Beep(20000,5000);
}
else
{US[row][column]='B';
cout<<"do You have a profile in here "<cin>>check;
if(check=='y')
{
cout<<"enter your profile number "<cin>>profile_number;
cout<<"please enter your passowrd"<cin>>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 "<cin>>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"<//Beep(20000,5000);
}
else
{UK[row][column]='B';
cout<<"do You have a profile in here "<cin>>check;
if(check=='y')
{
cout<<"enter your profile number "<cin>>profile_number;
cout<<"please enter your passowrd"<cin>>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 "<cin>>profile_password;
making_profile(profile_counter,profile_password,"UK",row,column);
}
cout<<"Your seat is BOOKED enjoy the flight"<}
else
cout<<"Invalid destination"<break;
}}
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;
}
}
}
}
Share:
by email on facebook on twitter
Explanation / Answer
il post the ques sometime later
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.