0% found this document useful (0 votes)
11 views4 pages

Java Flight Reservation System Project

The mini project implements a Flight Reservation System in Java, utilizing searching and sorting algorithms to manage flight data. Users can view, search, sort, and reserve flights, enhancing their understanding of data manipulation in real-world applications. The project employs an ArrayList to store flight details and includes features like linear search and sorting by price.

Uploaded by

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

Java Flight Reservation System Project

The mini project implements a Flight Reservation System in Java, utilizing searching and sorting algorithms to manage flight data. Users can view, search, sort, and reserve flights, enhancing their understanding of data manipulation in real-world applications. The project employs an ArrayList to store flight details and includes features like linear search and sorting by price.

Uploaded by

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

Mini Project Report

Project Title: Implementation of Flight Reservation


System[Searching and Sorting]

Language: Java

Abstract
This mini project implements a Flight Reservation System in Java
using Searching and Sorting algorithms. The system allows users to
view available flights, search for flights by source and destination, sort
the flights by ticket price, and reserve a flight. This project
demonstrates how searching and sorting can be applied to manage and
organize real-world data efficiently

Objective
The objective of this project is to apply the concepts of searching and
sorting in a real-world application scenario. By building a flight
reservation system, students can understand how data manipulation
and organization are used to simplify the user’s decision-making
process.

Tools & Technologies Used

1.  Programming Language: Java


2.  IDE: Eclipse / IntelliJ IDEA / NetBeans / BlueJ
3.  Concepts Used: Searching, Sorting, ArrayList, Classes and Objects, User Interaction

Algorithm
 Create a Flight class with attributes: flight number, source,
destination, and price.
 Store flight details in an ArrayList.
 Provide options to the user:
1. Display all flights
2. Search flight by source and destination
3. Sort flights by price
4. Reserve a flight
 Implement linear search to find matching flights.
 Implement sorting (Comparator-based or Bubble Sort) to
arrange flights by price.
 Allow the user to select a flight for reservation.
Source Code (Java)
import [Link].*;

class Flight {
String flightNumber;
String source;
String destination;
double price;

Flight(String flightNumber, String source, String destination, double price) {


[Link] = flightNumber;
[Link] = source;
[Link] = destination;
[Link] = price;
}

void display() {
[Link]("%-10s %-15s %-15s %-10.2f%n", flightNumber, source, destination,
price);
}
}

public class FlightReservationSystem {


static Scanner sc = new Scanner([Link]);
static ArrayList<Flight> flights = new ArrayList<>();

public static void main(String[] args) {


[Link](new Flight("AI101", "Pune", "Delhi", 4500));
[Link](new Flight("AI102", "Mumbai", "Goa", 3200));
[Link](new Flight("AI103", "Delhi", "Kolkata", 5600));
[Link](new Flight("AI104", "Chennai", "Bangalore", 2800));
[Link](new Flight("AI105", "Pune", "Hyderabad", 3900));

while (true) {
[Link]("\n1. Display Flights\n2. Search Flight\n3. Sort Flights by
Price\n4. Reserve Flight\n5. Exit");
[Link]("Enter your choice: ");
int choice = [Link]();
switch (choice) {
case 1: displayFlights(); break;
case 2: searchFlight(); break;
case 3: sortFlights(); break;
case 4: reserveFlight(); break;
case 5: [Link](0);
default: [Link]("Invalid choice");
}
}
}

static void displayFlights() {


[Link]("%-10s %-15s %-15s %-10s%n", "FlightNo", "Source", "Destination",
"Price");
for (Flight f : flights) [Link]();
}

static void searchFlight() {


[Link]();
[Link]("Enter source: ");
String src = [Link]();
[Link]("Enter destination: ");
String dest = [Link]();
boolean found = false;
for (Flight f : flights) {
if ([Link](src) && [Link](dest)) {
if (!found) [Link]("%-10s %-15s %-15s %-10s%n", "FlightNo",
"Source", "Destination", "Price");
[Link]();
found = true;
}
}
if (!found) [Link]("No flights found for given route.");
}

static void sortFlights() {


[Link]([Link](f -> [Link]));
[Link]("Flights sorted by price.");
displayFlights();
}
static void reserveFlight() {
[Link]();
[Link]("Enter flight number to reserve: ");
String fno = [Link]();
for (Flight f : flights) {
if ([Link](fno)) {
[Link]("Flight " + [Link] + " reserved successfully.");
return;
}
}
[Link]("Invalid flight number.");
}
}

Sample Output

Conclusion
This project successfully demonstrates how Stack and Queue data
structures can be used together to solve real-world problems. The
Palindrome Checker provides a clear understanding of LIFO and FIFO
principles in Java and how they can be applied to string processing.

Common questions

Powered by AI

The project highlights the practical use of Stack and Queue data structures, demonstrating LIFO (Last In, First Out) and FIFO (First In, First Out) principles, respectively. Specifically, the Palindrome Checker uses these structures to showcase how Java can manipulate strings efficiently by leveraging these order-processing principles, thereby solving real-world processing tasks .

The Flight Reservation System applies a linear search algorithm to allow users to search for flights by source and destination. This functionality enhances user interaction by allowing efficient retrieval of relevant flight data based on user input, thus streamlining the decision-making process for users when selecting flights .

The use of the ArrayList data structure allows dynamic storage and management of flight data, providing flexibility in adding or modifying flight details. This adaptability ensures that the operations for displaying, searching, and sorting flights are executed efficiently, supporting the system's requirements .

Using IDEs like Eclipse or IntelliJ IDEA provides robust support for coding, debugging, and managing Java projects. These environments offer features like code completion, syntax highlighting, and integrated debugging tools that facilitate efficient project development. Additionally, they support project organization, making it easier to manage class structures and dependencies in a project like the Flight Reservation System .

The Flight Reservation System incorporates user feedback through console prompts and error handling messages, improving usability by guiding users through available options and notifying them of invalid inputs. This interactivity helps prevent errors and ensures a smoother experience, facilitating user engagement with the system's features effectively .

A developer might select Bubble Sort for educational purposes or for small datasets where the simplicity of implementation outweighs performance concerns. Bubble Sort is a straightforward algorithm that provides a clear demonstration of sorting mechanics, which can be beneficial for learning and illustration in educational settings like this project .

The educational objectives include teaching students how to apply searching and sorting algorithms in real-world scenarios, enhancing their understanding of data manipulation and user-centric design. Through this project, students gain practical experience in implementing software that addresses real-life challenges, highlighting the importance of algorithm selection and user interface design in software development .

The Flight class encapsulates flight-related attributes such as flight number, source, destination, and price, which are essential for the system's operations. This encapsulation allows for easy management and manipulation of flight data using object-oriented principles, thus streamlining the implementation of searching, sorting, and display functionalities .

While linear search is easy to implement and understand, it is less efficient for large datasets due to its O(n) time complexity, particularly as the size of the flight list grows. In contrast, more advanced search algorithms like binary search, which have O(log n) complexity, could significantly enhance search performance if the data were sorted. The choice of linear search reflects a trade-off between simplicity and efficiency suitable for the moderate dataset size assumed in the project .

The system uses Comparator-based sorting to arrange flights by price, allowing users to view flights in order of cost. This sorting enhances user experience by facilitating easy comparison of flight options, thus aiding users in making informed decisions quickly and efficiently .

You might also like