Introduction
Electricity is one of the most important resources used in daily life. Every household,
industry, and organization consumes electricity for various purposes. Electricity
distribution companies charge customers based on the number of electricity units
consumed during a specific period. Traditionally, electricity billing was done
manually, which required a lot of time and effort and often resulted in calculation
errors.
With the advancement of computer technology, electricity billing systems can be
automated using software applications. An automated billing system helps in
calculating the bill quickly and accurately. It also improves efficiency and reduces the
chances of human errors.
The Electricity Billing System developed in this project is a simple desktop
application created using the Java programming language and Swing GUI
components. The system allows the user to enter customer details such as Customer
ID, Customer Name, and units consumed. Based on the entered units, the program
calculates the electricity bill using predefined tariff rates and displays the result in a
formatted bill.
This project demonstrates the practical use of Java GUI programming, event handling,
and logical conditions for building a simple billing application.
Objectives of the Project
The main objectives of developing the Electricity Billing System are:
To design and develop a simple electricity billing application using Java.
To automate the process of calculating electricity bills.
To provide a user-friendly graphical interface for entering customer details.
To reduce manual errors in electricity bill calculation.
To demonstrate the use of Java Swing components such as JFrame, JLabel,
JTextField, JTextArea, and JButton.
To understand event-driven programming in Java.
To generate a clear and formatted electricity bill for the customer.
This project helps students understand the basic concepts of Java GUI programming
and the implementation of simple business logic.
Problem Definition
In many traditional systems, electricity bills are calculated manually using calculators
or written records. This manual method has several disadvantages such as calculation
mistakes, slow processing, and difficulty in maintaining records.
Manual billing systems require more time and effort from employees and can lead to
incorrect billing if the calculations are not done properly. In addition, managing
customer information manually can become complicated when the number of
customers increases.
To overcome these problems, a computerized electricity billing system is required.
The proposed system allows the user to enter customer details and electricity units
consumed, after which the program automatically calculates the total bill amount.
This helps improve accuracy, reduce time consumption, and make the billing process
more efficient.
Electricity Billing Logic
The electricity billing system calculates the bill based on the number of units
consumed by the customer. Different electricity tariffs are applied for different ranges
of units.
The billing logic used in this project is based on a slab system where the rate per unit
increases as the consumption increases.
The billing rates used in the system are as follows:
Units Rate per
Consumed Unit
0 – 100 units ₹1.5 per unit
101 – 200 units ₹2.5 per unit
201 – 500 units ₹4 per unit
Above 500
₹6 per unit
units
For example, if a customer consumes 350 units, the bill is calculated as:
First 100 units = 100 × 1.5
Next 100 units = 100 × 2.5
Remaining 150 units = 150 × 4
Total bill amount = Sum of all calculated amounts.
This slab-based calculation ensures that customers who consume more electricity pay
a higher rate for additional units.
Algorithm
Step 1: Start the program.
Step 2: Display the electricity billing system window.
Step 3: Accept input from the user:
Customer ID
Customer Name
Units consumed
Step 4: Click the Calculate button.
Step 5: Read the number of units entered by the user.
Step 6: Check the unit range using conditional statements.
Step 7: Apply the billing formula according to the unit slab.
Step 8: Calculate the total electricity bill.
Step 9: Display the bill details in the text area.
Step 10: End the program.
Code:-
import [Link].*;
import [Link].*;
import [Link].*;
class ElectricityBillingSystem extends JFrame {
JTextField txtid, txtname, txtunit;
JTextArea txtbill;
JButton btncal, btnprint;
public ElectricityBillingSystem() {
setTitle("Electricity Billing System");
setSize(700,400);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(null);
JLabel titte = new JLabel("Electricity Billing System");
[Link](new Font("Arial", [Link], 22));
[Link](200,20,300,30);
add(title);
JLabel lblid = new JLabel("Customer ID");
[Link](50,100,100,30);
add(lblid);
txtid = new JTextField();
[Link](170,100,150,30);
add(txtid);
JLabel lblname = new JLabel("Customer Name");
[Link](50,150,120,30);
add(lblname);
txtname = new JTextField();
[Link](170,150,150,30);
add(txtname);
JLabel lblunit = new JLabel("Unit");
[Link](50,200,100,30);
add(lblunit);
txtunit = new JTextField();
[Link](170,200,150,30);
add(txtunit);
btncal = new JButton("Cal");
[Link](120,260,100,40);
add(btncal);
btnprint = new JButton("Print");
[Link](500,300,100,40);
add(btnprint);
txtbill = new JTextArea();
[Link](380,90,250,200);
[Link]([Link]([Link]));
add(txtbill);
// Calculate Button Action
[Link](new ActionListener() {
public void actionPerformed(ActionEvent e) {
int unit = [Link]([Link]());
double amount;
if(unit <= 100)
{
amount = unit * 1.5;
}
else if(unit <= 200)
{
amount = (100*1.5) + (unit-100)*2.5;
}
else if(unit <= 500)
{
amount = (100*1.5) + (100*2.5) + (unit-200)*4;
}
else
{
amount = (100*1.5) + (100*2.5) + (300*4) + (unit-500)*6;
}
[Link](
"Electricity Billing System\n\n" +
"Customer ID : " + [Link]() + "\n" +
"Customer Name : " + [Link]() + "\n" +
"Unit : " + [Link]() + "\n" +
"Amount : " + amount + "\n\n" +
"Thank You Come Again"
);
}
});
setVisible(true);
}
public static void main(String[] args) {
new ElectricityBillingSystem();
}
}
Output:-
Advantages and Future Enhancements
Advantages
Easy to use graphical user interface.
Reduces manual calculation errors.
Fast electricity bill generation.
Simple and efficient billing process.
Helps understand Java GUI programming.
Future Enhancements
The system can be improved by adding the following features:
Database connectivity to store customer records.
Automatic saving of billing history.
Online payment integration.
Printing and exporting bills in PDF format.
Advanced graphical interface design.
Multi-customer management system.
These improvements will make the system more powerful and suitable for real-world
applications.
Conclusion
The Electricity Billing System developed in this project successfully demonstrates
how electricity bills can be calculated automatically using a computer program. The
system provides a simple graphical user interface where users can enter customer
details and units consumed.
Using Java Swing components and event handling, the program calculates the bill
based on predefined tariff rates and displays the result instantly. This eliminates
manual calculation errors and makes the billing process faster and more efficient.
The project also helps in understanding important programming concepts such as
conditional statements, GUI design, and event-driven programming. With further
improvements such as database integration and advanced features, the system can be
expanded into a complete electricity billing management application.
References
Herbert Schildt – Java: The Complete Reference
Oracle Java Documentation=
Java Swing Tutorials from Oracle Official Website
Programming examples from Java GUI development guides
Online learning resources and Java programming tutorials