9 – Easy and simple billing system program in java swing

Easy and simple billing system program in java swing

Write a java program to present a set of choices for a user to select stationary product and display the price of product after selection from the list.

simple billing for Stationary

import java.awt.event.*;
import javax.swing.*;
import java.util.*;
public class MyStationery extends JFrame implements ActionListener
    HashMap<String, String> product_and_price;
    DefaultListModel<String> product_name_bill, product_quantity_bill,product_price_bill;
    JLabel product_name, price_per_unit, quantity_label, price_of_product, price_per_unit_label, total, total_amount, bill_product, bill_quantity, bill_price;
    JComboBox product_list, quantity_list;
    JList product_bill, product_quantity, product_price;
    JButton add_product;
    public MyStationery()
        product_and_price = new HashMap<String, String>();
        product_and_price.put("Book", "80");
        product_and_price.put("Pen", "10");
        product_and_price.put("Pencil", "7");
        product_and_price.put("Marker", "40");
        product_and_price.put("Eraser", "5");
        product_name_bill = new DefaultListModel<>();
        product_price_bill = new DefaultListModel<>();
        product_quantity_bill = new DefaultListModel<>();
        product_name = new JLabel("Product Name");
        quantity_label = new JLabel("Quantity");
        price_per_unit = new JLabel("Price Per Unit(₹)");
        price_per_unit_label = new JLabel("80");
        product_list = new JComboBox();
        quantity_list = new JComboBox();
        for(int i=1; i<=10; i++)
        bill_product = new JLabel("Item");
        bill_quantity = new JLabel("Quantity");
        bill_price = new JLabel("Cost");
        product_bill = new JList(product_name_bill);
        product_price = new JList(product_price_bill);
        product_quantity = new JList(product_quantity_bill);
        add_product = new JButton("Add Product");
        total = new JLabel("Total Amount : ");
        total_amount = new JLabel();
        product_name.setBounds(10, 30, 100, 20);
        price_per_unit.setBounds(160, 30, 100, 20);
        quantity_label.setBounds(310, 30, 100, 20);
        price_per_unit_label.setBounds(160, 50, 100, 20);
        product_list.setBounds(10, 50, 100, 20);
        quantity_list.setBounds(310, 50, 100, 20);
        add_product.setBounds(10, 80, 400, 50);
        bill_product.setBounds(10, 150, 150, 20);
        bill_quantity.setBounds(170, 150, 90, 20);
        bill_price.setBounds(270, 150, 140, 20);
        product_bill.setBounds(10, 175, 150, 400);
        product_quantity.setBounds(170, 175, 90, 400);
        product_price.setBounds(270, 175, 140, 400);
        total.setBounds(140, 575, 200, 20);
        total_amount.setBounds(310, 575, 90, 20);
        setTitle("My Stationery");
    public void actionPerformed(ActionEvent e)
            product_name_bill.addElement((String) product_list.getSelectedItem());
            product_quantity_bill.addElement((String) quantity_list.getSelectedItem());
            int unit_price = Integer.parseInt(product_and_price.get(product_list.getSelectedItem()));
            int product_quantity = Integer.parseInt((String) quantity_list.getSelectedItem());
            int total_for_product = unit_price*product_quantity; 
            int total_cost = 0;
            for(int i=0;i<product_price_bill.getSize();i++)
                total_cost += Integer.parseInt(product_price_bill.getElementAt(i));
        else if(e.getSource()==product_list)
    public static void main(String[] args)
        MyStationery ms = new MyStationery();


simple billing program in java swing itvoyagers


SYIT Practical Programs
SY-1-a Easy Java program to print multiplication table
SY-1-b Easy program to print inverted pyramid pattern of stars in Java
SY-1-c Easy Java program to print the area and perimeter of a circle
SY-2-c Easy Java program to reverse a string
SY-3-a Easy Java program to count the letters, spaces, numbers and other characters
SY-3-c Easy to find the smallest and largest element from the array in Java
SY-4-a Easy java program to sort array in ascending and descending order
SY-4-b Easy program on constructor and destructor in Java
SY-4-c Implementation of abstract class in Java in easy way
SY-5-a Easy java program to implement single level inheritance
SY-5-b Easy java program to implement method overriding
SY-5-c Easy java program to implement multiple inheritance
SY-6-a Easy program to create package in Java
SY-6-b easy java program to add two matrices and print the resultant matrix
SY-6-c Java program for multiplying two matrices in easy way
SY-7-a easy java program to implement the vectors
SY-7-c Easy and simple java program to implement multithreading
SY-8-a java program to open a file and display the contents in the console window in easy way
SY-8-b Java program to copy the contents from one file to other file in easy way
SY-9-a Java AWT program to print the factorial for an input value in easy way
SY-9-b Java AWT program to perform various string operations in easy way
SY-9-c Easy java program to implement exception handling
SY-10-a Java AWT program to accept and display student details in easy way
ST-10-b Java program to design a calculator based on AWT application in easy way
SYCS Practical Programs Semester 3
Java program to solve quadratic equations to print the roots of ax2+bx+c=0
Java program to add two matrices
Accept n strings. Sort names in ascending order
Create a package: Animals. In package animals create interface Animal with suitable behaviors. Implement the interface Animal in the same package animals
Demonstrate Java inheritance using extends keyword.
Demonstrate method overloading and method overriding in Java.
Demonstrate creating your own exception in Java.
Using various swing components design Java application to accept a student’s resume. (Design form)
Write a Java List example and demonstrate methods of Java List interface.
Design simple calculator GUI application using AWT components
Write a Java program that takes a number as input and prints its multiplication table upto 10.
Java program to print reverse pyramid
Write a Java program to print the area and perimeter of a circle
SYCS Practical Programs Semester 4
SYCS-5 Java application to demonstrate servlet life cycle in easy way
Practice Program
1 – Best Java program to find factorial of a number
2 – Java program to check if number is Even or Odd
3 – Best Java program to check prime number
4 – Simple and easy Java program to calculate area
5 – Best Java program to convert decimal to binary
6 – Best Java program to implement stack using array
7 – Best Java program to check palindrome number
8 – Best Java program to reverse a number
9 – Easy and simple billing system program in java swing
10 – Easy and simple java program for billing system of tour and travels
More coming soon…


We are aiming to explain all concepts of Java in easiest terms as possible.

Leave a Comment