0% found this document useful (0 votes)
3 views6 pages

Booking System Functionality Overview

The document outlines the functionalities of a booking system, detailing seven key functions including booking, cancellation, display, revenue calculation, and password generation. Each function is described with its purpose, steps, and a detailed explanation of its operation and significance in maintaining data integrity and user experience. The system ensures unique bookings, supports auditing, and provides financial reporting capabilities.

Uploaded by

raagpatel08
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views6 pages

Booking System Functionality Overview

The document outlines the functionalities of a booking system, detailing seven key functions including booking, cancellation, display, revenue calculation, and password generation. Each function is described with its purpose, steps, and a detailed explanation of its operation and significance in maintaining data integrity and user experience. The system ensures unique bookings, supports auditing, and provides financial reporting capabilities.

Uploaded by

raagpatel08
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Functionality – 1 : (book_ticket())

Purpose: Adds a booking to [Link] after validating inputs and ensuring the seat
isn’t already booked.

Steps:

Validate inputs (name, age, seat, bus number).

Scan [Link] for duplicate seat+bus.

If duplicate → reject booking.

If valid → generate timestamp + password.

Append booking to [Link].

Confirm success.

Detailed Explanation:

This function is the core of the booking system. It ensures that only valid and unique
bookings are stored. The first part checks for invalid inputs (like empty names or
negative ages), preventing garbage data from entering the file. Next, it opens
[Link] in read mode and scans every line using fgets() and sscanf(). By
extracting only the seat number and bus number, it checks whether the requested
seat is already taken on that bus. If a duplicate is found, the booking is rejected
immediately. If no conflict exists, the function generates a timestamp using
get_current_datetime() and appends the booking details to the file in CSV format. This
guarantees that every booking is traceable with a date/time and a unique password.
Finally, it prints a confirmation message to the user. In short, book_ticket() enforces
data integrity, uniqueness, and auditability in the reservation system.

Functionality – 2 : (cancel_booking())
Purpose: Cancels a booking by moving it to cancel_booking.csv and rewriting
[Link].

Steps:

Display all bookings.

Ask user for booking number.

Copy selected line to cancel_booking.csv.

Rewrite [Link] without that line.

Confirm cancellation.

CODE SNIPPET:

Detailed Explanation:

cancel_booking() is responsible for safe removal of bookings. It first loads all bookings
into memory, keeping the header intact. The user is shown the list of bookings (via
view_bookings()) and asked to select which one to cancel. The chosen record is
appended to cancel_booking.csv, ensuring that cancellations are logged for reporting.
Then, the function rewrites [Link] by copying all records except the cancelled
one into a temporary file. Finally, it replaces the old file with the new one using
remove() and rename(). This twostep process guarantees that the booking file is
never left in a corrupted state. By maintaining both active and cancelled records
separately, the system supports auditing, reporting, and revenue loss calculations.

Functionality – 3 : (display_csv_table())

Purpose: Displays CSV data in a formatted table.

Steps:

Clear console.
Print table header.

Read CSV line by line.

Tokenize with strtok().

Print aligned columns.

CODE SNIPPET:

Detailed Explanation:

This function is a utility for displaying CSV files in a humanreadable format. It opens
the specified file, skips the header row, and then reads each line. Using strtok(), it
splits the line into tokens separated by commas. Each token is printed with fixed width
formatting (%-20s) to align columns neatly. Row numbers are added to help users
select records (e.g., during cancellation). By abstracting the display logic into one
function, both bookings and cancellations can be shown consistently. This improves
user experience, readability, and reduces code duplication.

Functionality – 4 : (showBusRevenue())

Purpose: Calculates bus-wise revenue totals.

Steps:

Open [Link].

Parse bus number + fare.

Accumulate totals.

Print summary.

CODE SNIPPET:

Detailed Explanation:
This function provides the financial reporting capability of the system. It reads all
bookings, extracts the bus number and fare, and accumulates totals in an array
indexed by bus number. After processing, it prints a summary showing each bus’s
total revenue. This allows the admin to quickly assess which buses are generating the
most income. The design is simple but effective: it uses an array of fixed size (100
buses) and linear scanning. For larger systems, this could be replaced with dynamic
structures or a database. In the current project, it demonstrates file parsing,
aggregation, and reporting in C.

Functionality – 5 : (showCancelReport())

Purpose: Displays bus-wise cancellations and estimated loss.

Steps:

Open cancel_booking.csv.

Parse bus number + fare.

Count cancellations.

Estimate loss.

Print summary.

Functionality – 6 : (add_booking())

Purpose: Allows the admin to manually add a booking through console input.

Steps:

Clear screen and print “Add Booking” title.

Collect passenger details (name, age, gender, seat, phone, bus info, timings).
Confirm action with a Y/N prompt.

Generate a random booking password.

Set payment mode to “admin”.

Call book_ticket() to validate and store booking.

Pause to show confirmation.

CODE SNIPPET:

Detailed Explanation:

add_booking() is an interactive admin tool. It collects all booking details directly from
the console, ensuring that admins can add bookings without going through the
passenger flow. After gathering inputs, it asks for confirmation to prevent accidental
entries. A random password is generated for the booking, and the payment mode is
set to “admin” to distinguish these records. Finally, it calls book_ticket() to handle
validation and storage. This function demonstrates integration and reuse: instead of
writing storage logic again, it leverages existing functions. It’s especially useful for
testing and for cases where admins need to override passenger bookings.

Functionality – 7 :
(generate_booking_password())

Purpose: Generates a random alphanumeric password for each booking.

Steps:

Define a charset of uppercase letters and digits.

Loop for the required length.

Use rand() to pick random characters.


Append to password string.

Nullterminate the string.

CODE SNIPPET:

Detailed Explanation:

This function ensures that every booking has a unique identifier for cancellation
verification. It uses a simple random generator (rand()) to pick characters from a fixed
charset of uppercase letters and digits. The password length is typically 6 characters,
balancing usability and uniqueness. Although rand() is not cryptographically secure,
it’s sufficient for coursework. To avoid repeated sequences, the program should seed
the random number generator once at startup using srand(time(NULL)). By attaching
a password to each booking, the system adds a layer of security and traceability.

You might also like