C language version – data structure – final course design – major homework (airline passenger booking system) with source code + experimental documents

Design topic: Air passenger booking system

Knowledge involved in this project: pointers, structure arrays, linked lists, parameter passing

Need to add the author of the code

Require code +Q:2031234996

WeChat: QovS_Oct-16

Your likes, favorites, followers, and adding friends are the author’s greatest support.

 

[Problem Description] The business activities of air passenger ticket booking include querying route and ticket booking information, and can handle booking, refund, etc. A program is designed in C language to simulate and implement it.

1. Basic requirements:

1. The data information that the system needs to store includes:

(1) Flight information: city of arrival, flight number, aircraft number, takeoff and landing time, flight fare, total location and remaining locations, list of customers who have booked tickets. (Assuming the departure city is fixed)

(2) Customer information: customer name, ID number, seat number.

2. The operations and functions that the system can achieve.

(1) Ticket booking business: Query the flight information (including fare and number of remaining tickets) according to the customer’s requirements (city of arrival, departure and landing time, number of tickets booked), and if the requirements are met, the customer will be booked Procedure, enter the seat number.

(2) Undertake refund business: handle refund procedures for customers based on the information provided by the customer (flight number, ticket quantity).

3. Query function:

(1) Output relevant flight information based on flight number or arrival city.

(2) Query customer reservation information: output flight number, aircraft number and seat number based on customer ID number.

2. Design thinking:

With the development of the times, intelligent production has brought convenience and accuracy to society. This system was developed with the purpose of facilitating the public and properly managing airport ticketing operations. This program is developed using a data structure (described in C language) storage structure. Develop based on storage methods such as singly linked lists.

This system can provide ticket booking services to customers. If the flight tickets are sold out, relevant information will be prompted. Tickets can be refunded. After refunding, the relevant data files will be modified and saved. If there are any, tickets will be sold on a first-come, first-served basis. Customer information includes name, ID number, booking quantity and flight status, and the order has a number. Modify flight information: When the flight information changes, the flight data file can be modified.

3. Implementation:

Function module diagram:

4. Data structure description and module algorithm description

4.1. Browse route information module

Print out each message of the aircraft that has been defined in advance according to the lineinfo structure. First, wrap some output control characters in the display() function. After completing this step, define the list() function and implement it in the list function. The structure pointer and the structure array pointer are connected to each other to achieve the effect of assignment. Then, display() is continuously called using a loop auto-increment method to achieve the effect of outputting route information.

4.2. Browse the booked customer information module

The beginning of this module is to first call the flight information of the structure to get the flight number, and then call the find() function to get a pointer about the flight information, determine whether the pointer is empty, and then call the print function to print the flight number. All passenger information, the relevant flow chart is as follows:

4.3. Query the route module based on the terminal name

Enter the terminal name info->terminal_name according to the customer’s needs, and use the strcmp function, that is, strcmp (name, info->terminal_name) to compare. If they are the same, the flight information will be output. If they are different, the flight information will be output. “Sorry, the flight was not found!” The module function diagram is shown below:

4.4. Booking module

If the customer’s ticket booking amount exceeds the total number of passengers’ ticket bookings, exit. If the customer’s booking amount does not exceed the remaining number of tickets, the booking will be successful and the information will be recorded. as the picture shows:

4.5. Process refund module

Call the query function search(), call the find() function to search according to the route end point provided by the customer, and perform a loop query in the booking customer list field according to the name provided by the customer. If the name in the returned information is empty, it means that it has been found and exit this module. , and prompts (“Sorry, you have not booked a ticket!”) If the information query is successful, the customer’s order name will be found, and the pointer will be moved backward one position. When the next user purchases a ticket, the current one will be overwritten. This user who refunded the ticket has the effect of deleting the information in the booking customer list field by refunding the ticket, and re-points the route list field to the head pointer of the booking list to the head node of the waiting list queue. This module uses It is an algorithm that combines the sequential list and the single linked list. The sequential list is used to store all the information of each customer. Here all the information of each customer is the subject. The single linked list is used to store the information of multiple customers. Here multiple Customers are the subject.

4.6. Exit the system module

Use the break statement to exit the switch (statement) to exit the entire system.

 

5. Instructions for use

5.1. Query route:

Output the following information based on the terminal name proposed by the passenger: terminal name, flight number, aircraft number, flight date, flight fare, total location, and remaining tickets. The data for browsing route information is as follows. The system automatically adds 7 sets of data as reference. Enter the number 2 and then enter the destination to call up this page.

5.2. Handle ticket booking business:

According to the customer’s request (flight number, booking amount), the ticket amount of the flight will be checked. If there are remaining tickets, the booking procedure will be handled for the customer.

Output seat number: For customers who successfully purchase tickets, the system will automatically print the seat number. The specific operations and data addition of the ticket booking system are as follows. Enter the number 4 to enter this stage. After entering the relevant information, the system will automatically encrypt and save the phone number, which has the effect of protecting customer information.

5.3. Handle refund business:

Handle the refund procedure for the customer based on the information (name) provided by the customer. After purchasing the ticket, the customer may have the idea of ​​​​refunding the ticket or changing trains. At this time, the number 5 can be used to enter the refund system to perform related operations. To refund the ticket, you do not need to enter the ID and only need to enter the name of the person who booked the ticket. Refund successfully

5.4. Browse route information:

Print and enter all flight information: terminal name – flight number – aircraft number – flight date – flight fare – total location – remaining tickets. The data for browsing route information is as follows. The system automatically adds 7 sets of data as reference. Enter the number one to call up this page.

5.5. Browse customer information for booking tickets:

After entering the booking system to book a ticket, the customer will enter the passenger query interface for the aircraft. At this time, only the customer’s new information will be revealed, and the phone number entered previously has been encrypted. Enter the number 2 to enter this stage. Enter relevant information.

5.6. Exit the system:

After all operations are completed, the customer will have an operation to exit the system. Enter the number 6 to exit the booking system.

6. Operation results

6.1. The data for browsing route information is as follows. The system automatically adds 7 sets of data as reference. Enter the number one to call up this page:

Chinese page:

English page:

6.2. The specific operations and data addition of the ticket booking system are as follows. Enter the number 4 to enter this stage. After entering the relevant information, the system will automatically encrypt and save the phone number, which has the effect of protecting customer information.

6.3. After entering the booking system to book a ticket, the customer will enter the passenger query interface of the aircraft. At this time, only the customer’s new information will be revealed, and the phone number entered previously has been encrypted. Enter the number 2 to enter. At this stage, relevant information is entered.

 

6.4. Before booking a ticket, customers can check whether there are any available seats on the flight so that they can change the flight. Press the number 3 to enter the flight number, and enter the destination to query relevant fare information and seat information.

6.5. After purchasing the ticket, the customer may have the idea of ​​​​refunding the ticket or changing trains. At this time, the number 5 can be used to enter the refund system to perform related operations. To refund the ticket, you do not need to enter the ID and only need to enter the name of the person who booked the ticket. You can successfully refund the ticket:

6.6. After all operations are completed, the customer will have an operation to exit the system. Enter the number 6 to exit the booking system:

7, test process and result analysis

Input function: input of original data (input the basic information of the route through the structure array).

Query function: Query related routes according to customer needs.

Ticket booking function: satisfy customers’ ticket booking tasks.

The refund function exits the system.

7.1. Browse route information:

7.2. Browse the information of customers who have booked tickets:

7.3 Query route:

7.4 Handling refund business:

7.5, program improvement

For nearly a week, I continued to modify, compile, debug, and run the program and each module, and encountered many problems during the process:

(1) When the program was originally designed, overflow errors often occurred, and there were more than one. In order to correct these errors, a lot of time was spent. After correcting the explanation and looking at the source program, I found that it was just because there was a problem with the data type defined by the function at the beginning, the definition of the function was not clear, and the characters were incorrectly defined. A lot of error correction work was done later.

(2) Due to forgetting some C language specifications, some errors were not discovered during the debugging process. For example, when using a function, you only need to pass the array name for the array; the character ‘0’ is different from the 0 of the integer type, and you cannot directly draw an equal sign between them.

(3) Test cases have a certain extent. A variety of different character information was input when running the program, and after many modifications, the results achieved the expected results, indicating that the program has a certain degree of reliability and stability.

2. After continuous learning, this course design was finally completed. Although I benefited a lot in the end, there were still many shortcomings:

(1) Enter the system. Each data input will overwrite the data entered last time.

(2) The query system can only search for the most recently entered data, and only one message can be displayed for the same terminal. (3) When the data is initialized, the data is not stored in a certain order. If there is a lot of route information, data errors may occur.

(3) After the user purchases the wrong ticket, if he wants to change the ticket, he can only buy the ticket first -> refund the ticket -> buy the ticket. This is very time-consuming. It can be extended to directly select the correct flight and ticket number to save time. The effect also saves repeated operations and reduces the number of program runs.

source code:

Passenger initialization definition:

typedef struct ord_ros {
	char name[size];//Customer name
	int order_amount;//booking amount
	int IdNumber;//identity id
	struct ord_ros *next;
} linklist;
linklist *new,*p1,*head;

Flight initialization information definition:

typedef struct airline {
	char terminal_name[size];//Terminal station name
	char air_Numer[size];//flight number
	char plane_Numer[size];//Plane number
	char day[100];//flight date
	int ticket_price; //ticket price
	int Sum_Ticket_Numer;//Total position
	int ticket_sur;//Amount of remaining tickets
	linklist *order;//The crew list field points to the head pointer of the crew list linked list
} lineinfo;
lineinfo *start;

Print all flight information:

void list(){ 
	lineinfo *info;
	info=start;
	int i;
	printf("Terminal name\tflight number\taircraft number\t\tflight date\t\t\tflight fare\ttotal location\tremaining ticket amount");
	for(i=0;i<MAXSIZE;i++)
		display(info++);
	printf("\n\n");
}

Output route information based on the terminal name proposed by the customer:

void search(){
	struct airline *info,*find();
	char name[10];
	int i=0;
	info=start;
	printf("Please enter the terminal name:");
	scanf("%s",name);
	while(i<MAXSIZE) {
		if(!strcmp(name,info->terminal_name)) break;
		info++;
		i++;
	}
	if(i>=MAXSIZE)
		printf("Sorry, the route was not found!\n");
	else {
		printf("Terminal name\tflight number\taircraft number\t\tflight date\t\t\tflight fare\ttotal location\tremaining ticket amount");
		display(info);
	}
}

Print the customer list information in the booking crew list field:

void prtlink(){
	linklist *p;
	struct airline *info;
	info=find();
	p=info->order;
	if(p!=NULL) {
		printf("Customer name, booking amount, customer ID\n");
		while(p) {
			printf("%s\t\t%d\t%d\n",p->name,p->order_amount,p->IdNumber);
			p=p->next;
		}
	} else
    	printf("There is no customer information for this route!!\n");
}

Add customer information in the booking crew list field:

linklist *insertlink(linklist *head,int amount,char name[],int IdNumber){
	linklist *p1,*new;
	p1=head;
	new=(linklist *)malloc(sizeof(linklist));
	if(!new) {
		printf("\nOut of memory!!\n");
		return NULL;
	}
	strcpy(new->name,name);
	new->order_amount=amount;
	new->IdNumber=IdNumber;
	new->next=NULL;
	if(head==NULL) //If there is no booking customer information
	{
		head=new;
		new->next=NULL;
	} else
		head=new;
	new->next=p1;
	return head;
}

Handle ticket booking business:

void order(){
	struct airline *info;
	int amount,IdNumber;
	char name[10];
	info=start;
	if(!(info=find())) return;//Query based on the flight number provided by the customer. If it is empty, exit the module
	printf("Please enter the booking quantity you need:");
	scanf("%d",&amount);
	if(amount>info->Sum_Ticket_Numer){ //If the customer's ticket booking amount exceeds the total passenger ticket booking amount, exit
		printf("\nSorry, the number of tickets you entered has exceeded the passenger quota!");
		return;
	}
	if(amount<=info->ticket_sur){//If the customer's ticket booking amount does not exceed the remaining ticket amount, the ticket booking is successful and the information will be recorded.
		printf("Please enter your booking customer name:");
		scanf("%s",name);
		printf("Please enter %s's phone number:",name);
		scanf("%d",&IdNumber);
		info->order=insertlink(info->order,amount,name,IdNumber);//Add customer information in the booking crew list field
		for(int i=0; i<amount; i++) // Output the seat number of the booking customer in sequence
			printf("%s's seat number is:%d\n",name,info->Sum_Ticket_Numer-info->ticket_sur+i+1);
		info->ticket_sur-=amount;//The remaining tickets for the route should be reduced by the customer's booking amount
		printf("\nWish you a pleasant ride\n");
	} else
	printf("\nYou are welcome to order again next time\n");
}

Refund module:

void return_tkt(){
	struct airline *info;
	int IdNumber;
	linklist *p1,*p2,*head;
	char cusname[10];
	if(!(info=find())) return;//Call the query function to search based on the routes provided by the customer
	head=info->order;
	p1=head;
	printf("Please enter the name of the refund customer:");
	scanf("%s",cusname);
	while(p1!=NULL) {//Go to the ticket booking customer list field to query based on the name provided by the customer
		if(!strcmp(cusname,p1->name)) break;
		p2=p1;p1=p1->next;
	}
	if(p1==NULL) {
		printf("Sorry, you have not booked a ticket!\n"); //Exit this module if not found
		return;
	} else { //If the information query is successful, delete the information in the ticket booking customer list field
		if(p1==head) head=p1->next;
		else p2->next=p1->next;
		info->ticket_sur+=p1->order_amount;
		IdNumber=p1->IdNumber;
		printf("%s refunded successfully!!\n",p1->name);
	}
}

Menu interface:

int menu_select(){
	int c;
	printf("\t\tAir passenger booking system\n");
	printf("========================================\n");
	printf("1. Browse route information:\n");
	printf("2. Browse the customer information of booked tickets:\n");
	printf("3. Query route\n");
	printf("4. Handle ticket booking business:\n");
	printf("5. Handle refund business:\n");
	printf("6.Exit the system\n");
	printf("========================================\n");
	do {
		printf("Please select:");
		scanf("%d",&c);
	} while(c<0||c>7);
	return c;
}

Route module:

struct airline air_info[MAXSIZE]= {
{"Beijing","K12312","B8571","2021/07/05-13 00",509,100,100},
{"Shanghai","D24322","S1002","2021/07/06-13 00",529,100,100},
{"London","K35234","L1003","2021/07/07-13 00",642,100,100},
{"Hangzhou","D42414","B9571","2021/07/08-13 00",322,100,100},
{"Wuhan","K12314","B3451","2021/07/09-13 00",562,100,100},
{"Guangzhou","K64124","C3451","2021/07/10-13 00",645,100,100},
{"United States","H12412","M3451","2021/07/11-13 00",685,100,100} };
	start=air_info;

If you need a code, please add the following contact information:

+VX:

 

+QQ:

2031234996 (due to the QR code image review failing)

 

 

 

 

 

Related Posts

MySQL index classification and creation principles

[LeetCode]Replace spaces&&disappeared numbers&&split linked list&&product of arrays except itself

Shenzhou Loongson GSC3290 adapted to Yutai YT8521S operating instructions

Infinitus Classification

LeetCode 884 Uncommon words in two sentences [String] HERODING’s road to LeetCode

The four major characteristics of C++MySQL database operation statements and transactions

c++ student information management system

Basic operations of sequential stack (super detailed)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*