Bus Ticket Booking System Project Report
Bus Ticket Booking System Project Report
A PROJECT REPORT
SUBMITTED BY
INBARASAN K
ARUL MURUGAN M
MANUJ M
AARVALAN V
MAHENDHRACOLLEGEOFENGINEERING, MINNAMPALLI
SALEM-636106
CERTIFIED THAT THIS PROJECT REPORT “...BUS TICKET BOOKING SYSTEM ... ‘’
IS THE BONAFIED WORK OF “............................................”REG NO..................................
WHO CARRIED OUT THE PROJECT WORK UNDER MY SUPERVISION DURING THE
DEPARTMENT OF DEPARTMENT OF
We express our sincere gratitude to all those who guided and supported us
throughout the completion of this project, "BUS TICKET BOOKING SYSTEM."
Their invaluable assistance, insightful suggestions, and continuous encouragement
were instrumental in turning our efforts into reality.
We offer our heartfelt thanks to Anna University, Chennai 600 025 for providing
us with the opportunity and the academic framework to undertake this project as
partial fulfillment for the award of the degree of Bachelor of Engineering in
Information Technology.
We are deeply indebted to our college, Mahendhra College of Engineering,
Minnampalli, Salem-636106, for providing the necessary facilities and a
conducive learning environment. We extend our profound thanks to the Head of the
This section details the formal requirements and the architectural blueprint for the
Single-Page Bus Ticket Booking System (SPBTBS).
2.1 System Analysis
These define the specific actions the system must perform to satisfy user needs.
FR06 Payment
FR07 Confirmation Upon successful payment, a confirmation summary
(digital ticket) must be generated and displayed
instantly.
A mock administration interface must allow bus
FR08 Admin operators to add/update bus schedules and routes.
(Mock)
These define criteria used to judge the operation of the system, rather than
specific behaviors.
NFR01 Performance The search results page must load within 2 seconds, even with
a large dataset.
NFR02 Usability The entire booking process must be completed within a single,
responsive page (SPA design).
NFR04 Reliability The system must prevent concurrent users from booking the
same seat (atomic transaction guarantee).
The core entities and their relationships define how data is structured and stored to
support the booking logic.
This flowchart illustrates the primary process flow of the Single-Page Bus Ticket Booking
System (SPBTBS), detailing the interaction between the user and the system's core modules.
12. Decision: Application The system verifies the payment outcome. FR06
Payment Status Tier
13. Successful Data (IF YES): The system updates the seat FR07
Booking Management status from 'Reserved' to 'Booked', creates
Module a permanent record in the Booking entity,
and generates the digital ticket.
1. Main Module
Function: main()
Function: displayBusDetails()
Function: loadBusData()
Function: bookTicket()
Function: generatePNR()
Function: saveBookingToFile()
Function: cancelTicket()
Function: viewBookings()
Function: readFromFile()
Function: writeToFile()
9. Utility Module
Function: clearScreen()
Function: pause()
Function: printHeader()
• Source Code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 50
struct Bus {
int busNo;
char source[20];
char destination[20];
char time[20];
int totalSeats;
int availableSeats;
int fare;
};
struct Booking {
int pnr;
char name[30];
int age;
int busNo;
int seatNo;
int fare;
};
intbusCount = 5;
//Function Declarations
void loadBusData();
void displayBusDetails();
void bookTicket();
int generatePNR();
void viewBookings();
void cancelTicket();
intmain() {
int choice;
loadBusData();
do {
printf("\n===== BUS TICKET BOOKING SYSTEM =====\n");
printf("5. Exit\n");
scanf("%d", &choice);
switch(choice) {
}while(choice != 5);
return 0;
}
//Load Bus Data
void loadBusData() {
buses[0] = (struct Bus){101, "Salem", "Chennai", "6:00 AM", 40, 40, 350};
buses[1] = (struct Bus){102, "Salem", "Coimbatore", "7:30 AM", 45, 45, 300};
buses[2] = (struct Bus){103, "Salem", "Madurai", "9:00 AM", 50, 50, 400};
buses[3] = (struct Bus){104, "Salem", "Bangalore", "10:00 AM", 48, 48, 550};
buses[4] = (struct Bus){105, "Salem", "Trichy", "3:00 PM", 42, 42, 280};
//Display Buses
void displayBusDetails() {
}
//CheckSeat Availability
intcheckSeatAvailability(int busNo) {
if(buses[i].busNo == busNo)
return buses[i].availableSeats;
return-1;
//Generate PNR
intgeneratePNR() {
fclose(fp);
}
//Book Ticket
voidbookTicket() {
struct Booking b;
intbusNo;
scanf("%s", [Link]);
scanf("%d", &[Link]);
displayBusDetails();
scanf("%d", &busNo);
intseats = checkSeatAvailability(busNo);
if(seats <= 0) {
return;
}
[Link]=busNo;
[Link]=buses[busNo % busCount].fare;
[Link]=generatePNR();
// Reduce seat
if(buses[i].busNo == busNo)
buses[i].availableSeats--;
saveBooking(b);
printf("PNR:%d\n", [Link]);
printf("Fare:Rs.%d\n", [Link]);
struct Booking b;
if(fp == NULL) {
return;
fclose(fp);
}
//Cancel Ticket
void cancelTicket() {
int pnr;
scanf("%d", &pnr);
struct Booking b;
int found = 0;
if([Link]== pnr) {
found= 1;
//Increaseseatcount
for(inti=0;i<busCount; i++) {
if(buses[i].busNo == [Link])
buses[i].availableSeats++;
}
}else {
fclose(fp);
fclose(temp);
1. Introduction to Testing
Testing ensures that the Bus Ticket Booking System works correctly, handles user
inputs properly, and produces the expected output without errors. The following test
cases verify the core functions such as booking, cancellation, searching, and file
handling.
2. Test Cases
Test Case 1 – View Bus Details
Result Pass
The Bus Ticket Booking System can be improved and expanded with the following
enhancements:
6. QR Code Tickets
✅ Conclusion
✅ References
– C Basics
4. TutorialsPoint Programming
Section
(Syntax, functions, loops, file handling examples)
– C
5. GeeksforGeeks Programming
Overflow
(Reference for logical implementation and program structure)
6. Stack
(Used for troubleshooting coding errors and best practices)
This program allows a user to book, view, and check the status of bus seats.
C
#include #include #include #include <stdio.h>
<conio.h>
// #define <stdlib.h>
<string.h>
bus
Define the maximum number of seats on the
40
MAX_SEATS
// Define the filename for storing booking data
#define FILENAME "bus_bookings.dat"
details
// Structure to hold passenger
{
struct bus_booking
seat_num;
int
name[50];
char
mobile[15];
char
destination[50];
char
};
// Function prototypes
void menu();
void display_seats();
void book_ticket();
void view_bookings();
void load_data();
void save_data();
// Main function
int main() {
load_data(); // Load existing data from file at startup
menu();
return 0;
}
printf("\n\t\t==========================================");
printf("\n\t\t\tBUS TICKET BOOKING SYSTEM ");
printf("\n\t\t==========================================");
printf("\n\n\t[1] Display Bus Seat Status");
printf("\n\t[2] Book Ticket");
printf("\n\t[3] View All Bookings");
printf("\n\t[4] Exit Program");
printf("\n\n\tEnter your choice: ");
scanf("%d", &choice);
switch (choice) {
case 1:
display_seats();
break;
case 2:
book_ticket();
break;
case 3:
view_bookings();
break;
case 4:
save_data(); // Save data before exiting
printf("\n\tThank you for using the system.
Data saved successfully!\n");
printf("\tPress any key to exit...");
getch();
exit(0);
default:
printf("\n\tInvalid choice. Please try
again.");
getch();
}
} while (choice != 4);
}
// Function to load existing booking data from the file
{
void load_data()
*fp;
FILE
booking;
struct bus_booking
initially
// Reset all seat statuses to available {
for (int i = 0; i < MAX_SEATS; i++) 0;
seat_status[i] =
}
fp = fopen(FILENAME, "rb");
if (fp == NULL) {
// File does not exist, or is empty. Initializing an
empty file.
// printf("Booking file not found. Starting
fresh.\n"); // Debug message
return;
}
printf("\t==================================================
======================\n");
printf("\t\t\t\t[ A ] = Available, [ B ] = Booked\n");
printf("\t==================================================
======================\n\n");
int seat_num;
printf("\n\tEnter Seat Number to book (1-%d): ",
MAX_SEATS);
scanf("%d", &seat_num);
number
// Validate seat {
if (seat_num < 1 || seat_num > MAX_SEATS)
printf("\n\tInvalid seat number. Press any key to
continue...");
getch();
return;
}
printf("\n\t================================================
==");
printf("\n\tBOOKING SUCCESSFUL! Seat %d is booked for %s.",
seat_num, new_booking.name);
printf("\n\t================================================
==");
printf("\n\tPress any key to return to the menu...");
getch();
}
printf("\t==================================================
======================\n");
printf("\tSeat | Passenger Name\t| Mobile Number\t|
Destination\n");
printf("\t----------------------------------------------
--------------------------\n");
fclose(fp);
if (count == 0) {
printf("\n\tNo bookings found yet.");
}
printf("\t----------------------------------------------
--------------------------\n");
printf("\n\tTotal Bookings: %d", count);
printf("\n\tPress any key to return to the menu...");
getch();
}
Here is a step-by-step example of how the program would run, assuming the system
starts with no existing bookings.
Step 1: Main Menu
==========================================
BUS TICKET BOOKING SYSTEM
==========================================
===========================================================
=============
[ A ] = Available, [ B ] = Booked
===========================================================
=============
|
[A] 01 [A] 02 [A] 03 | [A] 04
|
| [A] 05 [A] 06 [A] 07 | [A] 08
[A] 09 [A] 10 [A] 11 | [A] 12
... (All 40 seats are [A] Available)
to menu...
Press any key return to the
==================================================
BOOKING SUCCESSFUL! Seat 10 is booked for Rahul Sharma.
==================================================
Press any key to return to the menu...
===========================================================
=============
[ A ] = Available, [ B ] = Booked
===========================================================
=============
|
[A] 01 [A] 02 [A] 03 | [A] 04
|
[A] 05 [A] 06 [A] 07 | [A] 08
[A] 09 | [B] 10 [A] 11 | [A] 12 <-- Seat 10 is now [B] Booked
...
Total Bookings: 1
Press any key to return to the menu...