Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

just do option 2,3,4,5 using 2 dimesional array to edit the file.please don\'t u

ID: 3710173 • Letter: J

Question


just do option 2,3,4,5 using 2 dimesional array to edit the file.please don't use classes.I will give you good rating.Thanks

The aim of this project is to implement a seat reservation system for a passenger airplane. We assume a small airplane with 10 rows and 4 seats per row. We assume that the seat chart is initially stored in a file "chartIn.txt" in the following format: A B C D 2 A B C D 3 A B C D 4 A BC D 5 ABC D 6 A B C D 7 A BC D 8 A BC D 9 A BC D 10 A B C D The example given above means that seats IA. IB, IC, ID. 2A, 2B 2C, 2D, 3A, are all available. Note that the number 1, 2, 3 also belong to the file. Below is another example of data stored in the file "chartIn.txt A X C D 2 A BC D 3 A B C D 4 A B C D 6 AB C D 7 A BC D 8 A BC D 10A X X D This second example demonstrates that the following seats marked with 'X' are reserved: 1B, 5B, 9C, 10B, 10C. The program must use a function to initially read the seat chart from the file "chartIn.txt" and fill out a 2-dimentional array called seatChart. The main program then calls a function to display the following menu:

Explanation / Answer

void reserveSeats(char seatChart[10][4]){

char seat[2];

printf("Enter seat number :");

scanf("%s",seat);

if(seatChart[seat[0]-'0'-1][seat[1]-'A']=='x'){ // check if not reserved

printf("Sorry!The seat is already reserved ");

}else{

seatChart[seat[0]-'0'-1][seat[1]-'A']='x';

printf("The seat has been successfully reserved ");

}

}

void cancelSeats(char seatChart[10][4]){

char seat[2];

printf("Enter seat number :");

scanf("%s",seat);

if(seatChart[seat[0]-'0'-1][seat[1]-'A']!='x'){ // check if reserved

printf("Sorry!The seat is not yet reserved ");

}else{

seatChart[seat[0]-'0'-1][seat[1]-'A']=seat[0];

printf("The seat has been successfully cancelled ");

}

}

void statistics(char seatChart[10][4]){

int i,j;

int numOfSeats;

double percent;

for(i=0;i<10;i++){

for(j=0;j<4;j++){

if(seatChart[i][j]!='x') // count available seats

numOfSeats++;

}

}

printf("Number of available seats are %d ",numOfSeats);

percent=((40-numOfSeats)*1.0/(10*4))*100; // total num of seats - available/total seats *100

printf("Percentage of reserved seats are %0.2f ",percent);

printf("List of available window seats :");

for(i=0;i<10;i++){

for(j=0;j<4;j++){

if((j==0||j==3)&&(seatChart[i][j]!='x'))// check window condition and reserved

printf("%d%c ,",i+1,j+'A');

}

}

printf(" List of available Aisle seats :");

for(i=0;i<10;i++){

for(j=0;j<4;j++){

if((j==1||j==2)&&(seatChart[i][j]!='x')) // check middle condition and reserved

printf("%d%c ,",i+1,j+'A');

}

}

}

void saveToFile(char seatChart[10][4]){

char *filename;

int i,j;

FILE * fp;

printf("Enter filename ");

scanf("%s",filename);

fp = fopen (filename,"w"); // open file in write mode

for(i=0;i<10;i++){

for(j=0;j<4;j++){

fprintf(fp,"%c ",seatChart[i][j]);

}

fprintf(fp," ");//add line space

}

}