0% found this document useful (0 votes)
4 views18 pages

Java Micro

Study with me

Uploaded by

janhavi1292006
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)
4 views18 pages

Java Micro

Study with me

Uploaded by

janhavi1292006
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
You are on page 1/ 18

Electricity Billing System

A
MICRO PROJECT
ON

“Electricity Billing System”

Under The Guidance


Mss. More S.S.

DEPARTMENT OF COMPUTER ENGINEERING


K.P. PATIL INSTITUTE OF TECHNOLOGY (POLY)
MUDAL-416209
Academic Year
2024-25

KPIT Page 1
Electricity Billing System

K. P. PATIL INSTITUTE OF TECHNOLOGY, MUDAL.


MICRO PROJECT ON
“Electricity Billing System”

CLASS: FIFTH SEMESTER


COURSE: COMPUTER ENGINEERING

SR.NO. STUDENT NAME ENR.NO ROLL. NO

1 SAI A. POWAR 2216610075 22


2 JANHAVI V. MANDAVKAR 2216610076 23
3 TUSHAR A. MASAVEKAR 2216610078 24

Signature of Signature of Signature of


Teacher Guide Head of Department Principal

KPIT Page 2
Electricity Billing System

INTRODUCTION :-
Electricity Billing System is a software-based application:-
i. This project aims at serving the department of electricity by computerizing the
billing system.
ii. It mainly focuses on the calculation of units consumed during the specified
time and the money to be charged by the electricity offices.
iii. This computerized system will make the overall billing system easy,
accessible, comfortable, and effective for consumers. To design the billing
system more service oriented and simple, the following features have been
implemented in the project. The application has high speed of performance with
accuracy and efficiency.
The software provides facility of data sharing, it does not require any staff as in
the conventional system. Once it is installed on the system only the meter
readings are to be given by the admin where customer can view all details, it has
the provision of security restriction.
The electricity billing software calculates the units consumed by the customer
and makes bills, it requires small storage for installation and functioning. There
is provision for debugging if any problem is encountered in the system.
The system excludes the need of maintaining paper electricity bill, administrator
does not have to keep amanual track of the users, users can pay the amount
without visiting the office. Thus, it saves human efforts and resources.
The main aim of our project is to satisfy customer by saving their time by
payment process, maintaining records, and allowing the customer to view
his/her records and permitting them to update their details.

KPIT Page 3
Electricity Billing System

OBJECTIVES :-
The objectives of our project are as follows:  To keep the information of
customer.
 To keep the information of consuming unit energy of current month.
 To keep the information of consuming unit energy of previous month.
 To calculate the units consumed every month regularly.
 To generate the bills adding penalty and rent.
 To save the time by implementing payment process online.

FLOWCHART :-

KPIT Page 4
Electricity Billing System

ER-Diagram :-

KPIT Page 5
Electricity Billing System

FIRST LEVEL DFD:-

SECOND LEVEL DFD:-

KPIT Page 6
Electricity Billing System

CODE:-
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.DecimalFormat;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
public class ElectricityBillingSystem extends JFrame implements
ActionListener {

KPIT Page 7
Electricity Billing System

// Define the components


private JTextField tfName, tfMeterNumber, tfUnitsConsumed;
private JButton btnCalculateBill, btnClear, btnExit;
private JLabel lblResult, lblName, lblMeterNumber, lblUnitsConsumed;
private JTextArea taResult;

// Constructor to set up the GUI


public ElectricityBillingSystem() {
setTitle("Electricity Billing System");
setSize(700, 500);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocationRelativeTo(null);

// Use BorderLayout for overall frame


setLayout(new BorderLayout());

// Header panel with a gradient background


JPanel headerPanel = new JPanel() {
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g;
GradientPaint gp = new GradientPaint(0, 0, new Color(0, 153, 255),
0, getHeight(), new Color(0, 102, 204));
g2d.setPaint(gp);
g2d.fillRect(0, 0, getWidth(), getHeight());
}
};
KPIT Page 8
Electricity Billing System

headerPanel.setPreferredSize(new Dimension(getWidth(), 60)


JLabel lblHeader = new JLabel("Electricity Billing System",
SwingConstants.CENTER);
lblHeader.setFont(new Font("Arial", Font.BOLD, 24));
lblHeader.setForeground(Color.WHITE);
headerPanel.add(lblHeader);
add(headerPanel, BorderLayout.NORTH);

// Main panel with form input fields


JPanel mainPanel = new JPanel();
mainPanel.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.insets = new Insets(10, 10, 10, 10);

// Name label and text field


lblName = new JLabel("Customer Name:");
tfName = new JTextField(20);
styleTextField(tfName);
gbc.gridx = 0; gbc.gridy = 0;
mainPanel.add(lblName, gbc);
gbc.gridx = 1;
mainPanel.add(tfName, gbc);
// Meter number label and text field
lblMeterNumber = new JLabel("Meter Number:");
tfMeterNumber = new JTextField(20);
styleTextField(tfMeterNumber);
gbc.gridx = 0; gbc.gridy = 1;
KPIT Page 9
Electricity Billing System

mainPanel.add(lblMeterNumber, gbc);
gbc.gridx = 1;
mainPanel.add(tfMeterNumber, gbc);

// Units consumed label and text field


lblUnitsConsumed = new JLabel("Units Consumed:");
tfUnitsConsumed = new JTextField(20);
styleTextField(tfUnitsConsumed);
gbc.gridx = 0; gbc.gridy = 2;
mainPanel.add(lblUnitsConsumed, gbc);
gbc.gridx = 1;
mainPanel.add(tfUnitsConsumed, gbc);

// Calculate, Clear and Exit buttons


btnCalculateBill = createButton("Calculate Bill", new Color(34, 139, 34));
btnClear = createButton("Clear", new Color(255, 69, 0));
btnExit = createButton("Exit", new Color(255, 0, 0));

gbc.gridx = 0; gbc.gridy = 3;
mainPanel.add(btnCalculateBill, gbc);
gbc.gridx = 1;
mainPanel.add(btnClear, gbc);
gbc.gridx = 0; gbc.gridy = 4;
mainPanel.add(btnExit, gbc);

// Result text area for showing bill details


taResult = new JTextArea(5, 30);
taResult.setEditable(false);

KPIT Page 10
Electricity Billing System

taResult.setFont(new Font("Arial", Font.PLAIN, 14));


taResult.setBackground(new Color(240, 248, 255));
JScrollPane scrollPane = new JScrollPane(taResult);
gbc.gridx = 1; gbc.gridy = 5;
mainPanel.add(scrollPane, gbc);

add(mainPanel, BorderLayout.CENTER);

// Action listeners for buttons


btnCalculateBill.addActionListener(this);
btnClear.addActionListener(this);
btnExit.addActionListener(this);
}

// Method to apply rounded style to text fields


private void styleTextField(JTextField textField) {
textField.setFont(new Font("Arial", Font.PLAIN, 14));
textField.setPreferredSize(new Dimension(200, 30));
textField.setBorder(BorderFactory.createLineBorder(new Color(100, 100,
255), 2, true)); // Rounded border
}

// Method to create buttons with hover effects and custom color


private JButton createButton(String text, Color color) {
JButton button = new JButton(text);
button.setFont(new Font("Arial", Font.BOLD, 16));
button.setBackground(color);
button.setForeground(Color.WHITE);
button.setFocusPainted(false);
KPIT Page 11
Electricity Billing System

button.setPreferredSize(new Dimension(160, 40));

button.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseEntered(java.awt.event.MouseEvent evt) {
button.setBackground(button.getBackground().darker()); // Darker
color on hover
}

public void mouseExited(java.awt.event.MouseEvent evt) {


button.setBackground(color); // Reset to original color when mouse
exits
}
});

return button;
}

// Action performed for button actions


@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == btnCalculateBill) {
calculateBill();
} else if (e.getSource() == btnClear) {
clearFields();
} else if (e.getSource() == btnExit) {
System.exit(0);
}
}

KPIT Page 12
Electricity Billing System

// Method to calculate the electricity bill


private void calculateBill() {
try {
String name = tfName.getText().trim();
String meterNumber = tfMeterNumber.getText().trim();
String unitsConsumedStr = tfUnitsConsumed.getText().trim();

if (name.isEmpty() || meterNumber.isEmpty() ||
unitsConsumedStr.isEmpty()) {
throw new Exception("Please fill in all fields.");
}

double unitsConsumed = Double.parseDouble(unitsConsumedStr);


if (unitsConsumed < 0) {
throw new Exception("Units consumed cannot be negative.");
}

// Calculate bill
double billAmount = 0.0;
if (unitsConsumed <= 100) {
billAmount = unitsConsumed * 1.5;
} else if (unitsConsumed <= 200) {
billAmount = 100 * 1.5 + (unitsConsumed - 100) * 2.0;
} else {
billAmount = 100 * 1.5 + 100 * 2.0 + (unitsConsumed - 200) * 3.0;
}

// Format bill amount


DecimalFormat df = new DecimalFormat("###.##");
KPIT Page 13
Electricity Billing System

// Display the result in the text area


taResult.setText("Customer: " + name + "\n" +
"Meter Number: " + meterNumber + "\n" +
"Units Consumed: " + unitsConsumed + " kWh\n" +
"Total Bill: ₹" + df.format(billAmount));
} catch (NumberFormatException ex) {
JOptionPane.showMessageDialog(this, "Please enter valid numeric
values for units consumed.", "Input Error", JOptionPane.ERROR_MESSAGE);
} catch (Exception ex) {
JOptionPane.showMessageDialog(this, ex.getMessage(), "Error",
JOptionPane.ERROR_MESSAGE);
}
}

// Method to clear all input fields and result area


private void clearFields() {
tfName.setText("");
tfMeterNumber.setText("");
tfUnitsConsumed.setText("");
taResult.setText("");
// Main method to run the application
public static void main(String[] args) {
SwingUtilities.invokeLater(() -> {
ElectricityBillingSystem app = new ElectricityBillingSystem();
app.setVisible(true);
});
}
}

KPIT Page 14
Electricity Billing System

OUTPUT:-

KPIT Page 15
Electricity Billing System

KPIT Page 16
Electricity Billing System

CONCLUSION:-
Usability testing was part of the post implementation review and performance
evaluation for the Electricity Online Bill Payment System, in order to ensure
that the intended users of the newly developed system can carry out the
intended task effectively using real data so as to ascertain the acceptance of the
system and operational efficiency.
It caters for consumers’ bills and also enables the administrator to generate
monthly reports. It is possible for the administrator to know the consumers have
made payment in respect of their bills for the current month, thereby improving
the billing accuracy, reduce the consumption and workload on the Electricity
Board employees or designated staff., increase the velocity of electricity
distribution, connection, tariff scheduling and eliminates variation in bills based
on market demand.
The conceptual framework allows necessary adjustments and enhancement
maintenance to integrate future demands according to the technological or
environmental changes with time. It manages the consumers’ data and validates
their input with immediate notification centralized in Electricity Board offices
across the nation.

REFERENCES:-
[1]. Arimoro, T. A., Oyetunji, A. K., &Odugboye, O. E. (2019).
Analysis of Electricity Billing System in Corporate Buildings in Lagos,
Nigeria. Studies, 1(6), 10-20.
[2]. Panthala, S., Islam, N., & Habib, S. A. (2015).
Automated industrial load measurement system. [3]. Adegboyega, A.,
Gabriel, A. A., Ademola, A. J., Victor, A. I., &Nigeri, K. (2013).
Design and Implementation of an Enhanced Power Billing System for
Electricity Consumers in Nigeria. African Journal of Computing & ICT,
6(1).
https://www.google.com/

KPIT Page 17
Electricity Billing System

KPIT Page 18

You might also like