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

Airline Scheduling Project Write a reservation system for an airplane flight. As

ID: 3688669 • Letter: A

Question

Airline Scheduling Project

Write a reservation system for an airplane flight. Assume the airline has 5 rows with 3 seats in each row (small plane!). Use a 2 dimensional array of type string to maintain a seating chart. In addition, create an array to be used as a waiting list in case the plane is full. The waiting list should be "first come, first served"; that is, people who are added early to the list get priority over those added later. Also, you must maintain a second 2 dimensional array (a parallel array) that reflects the cost of the seats. Pricing for the seat is described below. Keep a running tally of the money earned on each flight. Allow the user the following options:

1. Add a passenger to flight or waiting list

a. Request the passenger list

b. Display a chart of the seats in the airplane in tabular form, clearly titled, with the row and seat numbers clearly listed

c. If seats are available, let the passengers choose a seat. Inform the passenger of the seating cost. Add the passenger to the seating chart.

d. If no seats are available, place the passenger on the waiting list. Assume that the waiting list will grow to a maximum capacity of 10 passengers.

2. Remove a passenger from a flight

a. Search seating chart in the plane for a given name and delete this name from the seating chart. Ask for confirmation prior to deletion. There will not be any duplicate names.

b. If waiting list is empty, update the array so seat is available.

c. If waiting list is not empty, remove the first person from list, give him/her the newly vacated seat.

3. Allow the user an option to display the passenger list or the seating price list as desired.

4. Initialize the arrays that are used in the following manner:

(a) Initialize string arrays to “xxxxx”

(b) Initalize numeric arrays to 0.00

5. Seat pricing.

a. Seats in the first 2 rows are first class and cost $200.00

b. Seats in the last 3 rows are coach class and cost $100.00

c. Seats in the middle receive a 10% “discomfort” discount.

Create and implement functions as you think best. (Use them to the maximum extent.) Code your program so that the main( ) function is of small size and relies upon the functions created to achieve to functionality described above. [Remember, arrays are always passed by reference. If you need to change an array, do it within a function and the array, as seen from the main, will also be changed.]

Explanation / Answer

#include<stdio.h>
#include<stdbool.h>
#include<string.h>
char *p[5][3],*w[10];
int pr[5][3],amount=0,i,j,k=0;
//function to create and initialize all flight lists
void flightCharts()
{
//initilialize passengera nd waiting list to "xxxxx"
for(i=0;i<5;i++)
for(j=0;j<3;j++)
p[i][j]="xxxxx";
for(i=0;i<10;i++)
w[i]="xxxxx";
//initialize price array to 0
for(i=0;i<5;i++)
for(j=0;j<3;j++)
pr[i][j]=0;

}
//function to set prices to the seats
void setPrice()
{
int i,j;
for(i=0;i<2;i++)
for(j=0;j<3;j++)
pr[i][j]=200;
for(i=3;i<5;i++)
for(j=0;j<3;j++)
pr[i][j]=100;
for(j=0;j<3;j++)
pr[2][j]=90;

}
//function to check if seat is available
bool isPassavailable()
{
for(i=0;i<5;i++)
{
for(j=0;j<3;j++)
{
if(strcmp(p[i][j],"xxxxx")==0)
return true;
}
}
return false;
}
//function to check if waiting list is full or not
bool isWait()
{
for(i=0;i<10;i++)
{
if(strcmp(w[i],"xxxxx")==0)
return true;
}
return false;
}
//function to add passenger
void addPass()
{
char *name;
int r,c;
printf("enter passenger name ");
scanf("%s",name);
//if seats available add passenger by asking seat details
if(isPassavailable)
{
printf("choose a seat ");
printf(" enter row,column ");
scanf("%d%d",&r,&c);
*p[r][c]=*name;
amount=amount+pr[r][c];
}//if no seat available add to waiting list
else if(isWait){
printf("passenger list is full you are being added to waiting list ");
while(strcmp(w[k],"xxxxx")!=0)
k++;
*w[k]=*name;
}//if waiting list full
else
{
printf("sorry, both passenger list and waiting list are full ");
}

}
//functtion to remove passenger
void removePass()
{
char *x;
int r,c,flag=0;
printf("enter passenger name to remove ");
scanf("%s",x);
for(i=0;i<5;i++)
{
for(j=0;j<3;j++)
{
if(strcmp(x,p[i][j])==0)
{
flag=1;
r=i;
c=j;
*p[i][j]=*w[i];
for(k=0;k<10;k++)
*w[k]=*w[k+1];
}
}
}
if(flag==0)
printf("name not on list ");
}
void displayList()
{
for(i=0;i<5;i++)
{
for(j=0;j<3;j++)
{
printf("%s ",p[i][j]);
}
printf(" ");
}
}
void ViewPrice()
{
for(i=0;i<5;i++){
for(j=0;j<3;j++){
printf("%d ",pr[i][j]);
}
printf(" ");
}
}
int main()
{
int ch;
//take choice from user
printf("enter choice 1.Add Passenger 2.Remove Passenger 3.ViewList 4.ViewPrice ");
scanf("%d",&ch);
flightCharts();
setPrice();
switch(ch)
{
case 1:addPass();
break;
case 2:removePass();
break;
case 3: displayList();
break;
case 4: ViewPrice();
break;
default : printf("enter valid choice!! ");
break;
}
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote