AJP Project .
AJP Project .
1. Introduction 1
2. Diagram 3
3. Code 5
4. Output 10
5. Conclusion 11
6. References 12
Car Rental System
Introduction
The Car Rental System in Advance Java using AWT (Abstract Window Toolkit) and Swing is
a graphical application that allows users to book, manage, and return rental cars. This system
can be developed by integrating event handling, AWT/Swing components for the user interface,
and database connectivity (e.g., using JDBC) for persistent storage of data.
AWT and Swing are used to design the graphical user interface.
AWT provides basic components like buttons, text fields, labels, and panels.
Swing is built on AWT, providing more sophisticated GUI components like JFrame, JButton,
JTextField, JLabel, JPanel, etc.
Components like JTable can be used to display available cars, bookings, and customer details.
2. Event Handling:
Event handling allows the program to respond to user actions, such as clicking buttons,
selecting options, or submitting forms.
In Java, event listeners like ActionListener, MouseListener, and KeyListener are used to
manage user interactions.
Each user action (e.g., clicking a "Book" button) triggers an event that invokes a specific piece
of code (event handler).
Java Database Connectivity (JDBC) is used to connect the application with a database (e.g.,
MySQL, PostgreSQL).
The database stores information such as customer data, available cars, booking records, and
payment details.
JDBC operations such as querying the database (SELECT), inserting new data (INSERT),
updating existing records (UPDATE), and deleting data (DELETE) are utilized.
1
Soniya Gandhi Polytechnic Shrigonda
Car Rental System
System Modules:
1. User Authentication:
Different roles with different access levels (admin can manage cars, customers can book cars).
2. Car Management:
Admin functionality to add, modify, and delete cars from the system.
Car details like model, price, availability status are stored in the database.
3. Booking System:
Customers can browse available cars and book them for a specific duration.
Booking details, customer information, and car status are updated in real-time.
4. Payment System:
Option to handle payments (e.g., via credit card or cash on return) and calculate the rental fee
based on the number of days.
After using the car, customers can return the car, and the system updates the availability status.
2
Soniya Gandhi Polytechnic Shrigonda
Car Rental System
The Data Flow Diagram (DFD) for the Car Rental System provides a visual representation of
the data interactions within the application. It highlights how users interact with the system
through the GUI, how events are triggered, and how data flows to and from the database.
Components
1. User
o Users can browse car listings, book rentals, manage accounts, and process
payments.
2. GUI
o Features forms, buttons, and menus for searching cars, booking rentals, and
viewing transaction history.
3. Event
3
Soniya Gandhi Polytechnic Shrigonda
Car Rental System
4. Database
o Contains information such as user profiles, car inventory, booking details, and
payment records.
Data Flow
1. User Action: A user interacts with the GUI (e.g., searching for available cars).
3. Database Query: The event queries the database for relevant information.
o Output: Updated information displayed on the GUI (e.g., list of available cars).
5. User Confirmation: The user receives feedback on their action through the GUI.
The data flow in the Car Rental System illustrates the interaction cycle between users and the
system. Users engage with the GUI, triggering events that query the database, ensuring real-
time updates and feedback. This flow enhances user experience by making the car rental
process efficient and effective. The DFD serves as a valuable tool to visualize and understand
the workflow of the system, ensuring clarity in its operation and design.
4
Soniya Gandhi Polytechnic Shrigonda
Car Rental System
Code
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
public CarRentalSystem()
connectDatabase();
5
Soniya Gandhi Polytechnic Shrigonda
Car Rental System
panel.add(modelField);
panel.add(regNumberField);
panel.add(addButton);
panel.add(rentButton);
panel.add(returnButton);
panel.add(displayButton);
panel.add(new JScrollPane(displayArea));
add(panel);
setDefaultCloseOperation(EXIT_ON_CLOSE);
pack();
setVisible(true);
try {
connection = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe",
"SYSTEM", "om2006");
System.out.println("Database connected!");
6
Soniya Gandhi Polytechnic Shrigonda
Car Rental System
} catch (SQLException e) {
e.printStackTrace();
stmt.setString(1, model);
stmt.setString(2, regNumber);
stmt.executeUpdate();
modelField.setText("");
regNumberField.setText("");
} catch (SQLException e) {
displayArea.setText("");
7
Soniya Gandhi Polytechnic Shrigonda
Car Rental System
while (rs.next()) {
} catch (SQLException e) {
e.printStackTrace();
stmt.setString(2, regNumber);
if (rowsUpdated > 0) {
} else {
} catch (SQLException e) {
e.printStackTrace();
8
Soniya Gandhi Polytechnic Shrigonda
Car Rental System
stmt.setString(2, regNumber);
if (rowsUpdated > 0) {
} else {
} catch (SQLException e) {
e.printStackTrace();
SwingUtilities.invokeLater(CarRentalSystem::new);
9
Soniya Gandhi Polytechnic Shrigonda
Car Rental System
Output
10
Soniya Gandhi Polytechnic Shrigonda
Car Rental System
Conclusion
The Car Rental System project effectively demonstrates the integration of advanced Java
technologies, including AWT, Swing, event handling, and database connectivity, to create a
robust and user-friendly application. The Data Flow Diagram (DFD) illustrates the seamless
interaction between users, the graphical interface, and the underlying database, highlighting
the system’s efficiency in managing car rentals.
Through this project, users can effortlessly browse available cars, manage bookings, and
process payments, all while receiving real-time updates and feedback. The use of event-driven
programming ensures that the system responds dynamically to user actions, enhancing the
overall experience.
This project not only showcases the practical application of Java programming but also
emphasizes the importance of a well-structured design in software development. By
implementing clear data flows and user interactions, the Car Rental System stands as a
comprehensive solution for managing rental operations, paving the way for further
enhancements and scalability in future iterations.
11
Soniya Gandhi Polytechnic Shrigonda
Car Rental System
Refernces
1. https://www.w3schools.com/java/
2. https://www.javatpoint.com/awt-and-swing-in-java
3. https://www.javatpoint.com/event-handling-in-java
4. https://www.geeksforgeeks.org/introduction-to-jdbc/
5. https://www.youtube.com/watch?v=7v2OnUti2eM
12
Soniya Gandhi Polytechnic Shrigonda