0% found this document useful (0 votes)
237 views

C Language Project (Airline Booking)

This project report describes an airline booking program written in C. The program uses a linked list data structure to store passenger information and allows users to reserve and cancel seats on flights through a menu-driven interface. It displays four options: reservation, cancellation, viewing booked flights, and exiting the program. The program is designed to handle up to 15 seats on a flight and saves passenger details to a file when the user exits.

Uploaded by

techstack901
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
237 views

C Language Project (Airline Booking)

This project report describes an airline booking program written in C. The program uses a linked list data structure to store passenger information and allows users to reserve and cancel seats on flights through a menu-driven interface. It displays four options: reservation, cancellation, viewing booked flights, and exiting the program. The program is designed to handle up to 15 seats on a flight and saves passenger details to a file when the user exits.

Uploaded by

techstack901
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

A

PROJECT REPORT
ON

“AIRLINE BOOKING”

SUBMITTED TO

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION,


MUMBAI
BY

MR. MANMODE ANIRUDDHA BADRINATH

DIPLOMA IN
COMPUTER ENGINEERING

UNDER GUIDENCE OF
PROF. DHONDE. S.A

DEPARTMENT of Computer

A.C.S.’S
DIPLOMA IN ENGINEERING AND TECHNOLOGY, ASHTI
(2022-2023)

A.C.S.’S

`A.C.S.’S. DIPLOMA IN ENGG & TECH, ASHTI Page | 1


DIPLOMA IN ENGINEERING AND TECHNOLOGY,
ASHTI - 414203

CERTIFICATE
This is to Certify that the project report entitled
“Airline Booking”
Submitted by
1. Mr. Manmode Aniruddha Badrinath 2215020052
2. Mr. Kharat Chetan Sanjay 2215020051
3. Miss. Khote Ashwini Ankush 2215020038

In the academic year 2022-2023 in the partial fulfilment of second semester diploma in computer
engineering. It is certified that all suggestion indicated for internal assessment have been incorporated in report.
The project has been approved as it satisfies the academic requirement in respect work prescribed for the said
degree.

Prof. Dhonde.S.A. Prof. Dhonde.S.A.


(Guide) (HOD)

SIGNATURE OF EXAMINER……………. Prof. Done.l.S.


(Principal)
INDEX

`A.C.S.’S. DIPLOMA IN ENGG & TECH, ASHTI Page | 2


Sr.No. Contents Pg.No.
Cover Page 1
Certificate 2
Index 3
1 Introduction 4
2 The working of program 5
Reference 11

1. Introduction

`A.C.S.’S. DIPLOMA IN ENGG & TECH, ASHTI Page | 3


This program is a simple airline booking system that allows users to reserve
and cancel seats on flights. The program uses C language and a linked list data structure to
store and manipulate the passenger information. The program also saves the passenger details
in a file when the user exits the program. The program has a user-friendly interface that
displays a menu with four options: reservation, cancel, display records and exit. The user can
choose any option by entering the corresponding number. The program validates the user
input and performs the required actions. The program is designed to handle up to 15 seats on
a flight and can be easily modified to accommodate more features or flights.

 Specialties

 This is a C program that provides a simple menu-driven interface for booking


flights, viewing booked flights, and canceling bookings.

 The program uses a struct data type to store booking information, including
the passenger's name and the flight number.

 The program restricts the number of bookings to a maximum of five and the
length of passenger names to a maximum of 50 characters.

 The program includes input validation to ensure that valid flight numbers are
entered, and it prevents double-booking by checking for duplicate bookings
before adding a new booking.

 Overall, this program provides a basic framework for managing flight


bookings in a simple, command-line environment.

2. The working of program

`A.C.S.’S. DIPLOMA IN ENGG & TECH, ASHTI Page | 4


This is a program written in the C programming language that provides a simple menu-driven
interface for booking flights, viewing bookings, and canceling bookings.

The program uses several predefined constants, including MAX_FLIGHTS (the maximum
number of flights that can be booked), and MAX_NAME_LEN (the maximum length of a
passenger's name).

It also defines a Booking structure that contains two fields, name (a character array of length
MAX_NAME_LEN) and flight_num (an integer representing the flight number).

The program also declares two global variables, bookings (an array of Booking structures)
and num_bookings (an integer representing the number of bookings made so far).

`A.C.S.’S. DIPLOMA IN ENGG & TECH, ASHTI Page | 5


2.1 Book a flight

The program includes three functions: book_flight, view_bookings, and cancel_booking. The
book_flight function allows the user to book a flight by entering their name and the flight
number they want to book.

2.2 Book_Flight Function 2.3 Cancel_Booking Function

2.4 View_Booking Function

If the flight is already booked or if the maximum number of flights has been reached, the
function informs the user and returns. If the booking is successful, the function adds the
booking to the bookings array and increments num_bookings.

`A.C.S.’S. DIPLOMA IN ENGG & TECH, ASHTI Page | 6


2.5 View booked flights

The view_bookings function simply displays all the bookings that have been made so far. If
there are no bookings, the function informs the user and returns.

2.6 Cancel a booking

The cancel_booking function allows the user to cancel a booking by entering their name and
the flight number they want to cancel. If the booking is found, the function removes it from
the bookings array and decrements num_bookings.

If the booking is not found, the function informs the user and returns.

2.7 Exit

Finally, the main function provides a menu-driven interface for the user. The user can choose
to book a flight, view bookings, cancel a booking, or exit the program. Invalid choices are
handled gracefully by informing the user and returning to the menu.

`A.C.S.’S. DIPLOMA IN ENGG & TECH, ASHTI Page | 7


The program runs indefinitely until the user chooses to exit.

 Source Code:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_FLIGHTS 6
#define MAX_NAME_LEN 50

typedef struct {
char name[MAX_NAME_LEN];
int flight_num;
} Booking;

Booking bookings[MAX_FLIGHTS];
int num_bookings = 0;

void book_flight() {
if (num_bookings >= MAX_FLIGHTS) {
printf("All flights are booked. Please try again later.\n");
return;
}

char name[MAX_NAME_LEN];
int flight_num;
printf("Enter your name: ");
scanf("%s", name);
printf("Enter the flight number you want to book (1-5): ");
scanf("%d", &flight_num);

if (flight_num < 1 || flight_num > MAX_FLIGHTS) {


printf("Invalid flight number. Please try again.\n");
return;
}

int i;
// Check if flight is already booked
for (i = 0; i < num_bookings; i++) {
if (bookings[i].flight_num == flight_num) {
printf("Flight %d is already booked by %s.\n", flight_num, bookings[i].name);
return;
}
}

// Add booking
Booking new_booking;
strcpy(new_booking.name, name);
new_booking.flight_num = flight_num;
bookings[num_bookings] = new_booking;
num_bookings++;

printf("Flight %d booked for %s.\n", flight_num, name);


}

void view_bookings() {
if (num_bookings == 0) {
printf("No flights have been booked.\n");

`A.C.S.’S. DIPLOMA IN ENGG & TECH, ASHTI Page | 8


return;
}

int i;
printf("Booked flights:\n");
for ( i = 0; i < num_bookings; i++) {
printf("Flight %d booked by %s.\n", bookings[i].flight_num, bookings[i].name);
}
}

void cancel_booking() {
if (num_bookings == 0) {
printf("No flights have been booked.\n");
return;
}

char name[MAX_NAME_LEN];
int flight_num;
printf("Enter your name: ");
scanf("%s", name);
printf("Enter the flight number you want to cancel (1-5): ");
scanf("%d", &flight_num);

if (flight_num < 1 || flight_num > MAX_FLIGHTS) {


printf("Invalid flight number. Please try again.\n");
return;
}

int i;
// Find booking to cancel
int index_to_remove = -1;
for ( i = 0; i < num_bookings; i++) {
if (strcmp(bookings[i].name, name) == 0 && bookings[i].flight_num == flight_num) {
index_to_remove = i;
break;
}
}

if (index_to_remove == -1) {
printf("No booking found for flight %d by %s.\n", flight_num, name);
return;
}

// Remove booking
for ( i = index_to_remove; i < num_bookings - 1; i++) {
bookings[i] = bookings[i+1];
}
num_bookings--;

printf("Booking for flight %d by %s cancelled.\n", flight_num, name);


}

int main() {

int choice;

while (1) {
system("cls");
printf("Menu:\n");
printf("1. Book a flight\n");

`A.C.S.’S. DIPLOMA IN ENGG & TECH, ASHTI Page | 9


printf("2. View booked flights\n");
printf("3. Cancel a booking\n");
printf("4. Exit\n");
printf("Enter your choice (1-4): ");
scanf("%d", &choice);

switch (choice) {
case 1:
book_flight();
break;
case 2:
view_bookings();
break;
case 3:
cancel_booking();
break;
case 4:
printf("Exiting program. Goodbye!\n");
exit(0);
default:
printf("Invalid choice. Please try again.\n");
}
getch();
}

return 0;
}

 References
1) Figures are download from www.msbte.com
2) www.google.com

`A.C.S.’S. DIPLOMA IN ENGG & TECH, ASHTI Page | 10


3) www.nationalgeographic.com
4) www.energyeduction.ca
5) For type this project we have use a MS-word
6) And we have completed this project under guidance of Prof. Dhonde. S. A

`A.C.S.’S. DIPLOMA IN ENGG & TECH, ASHTI Page | 11

You might also like