Write a java program to generate invoice
In todays post I am going to write a Java Program that will generate a invoice for your shop or any other purpose. Also, I am going to explain the program and show a demo by a video.
рдЖрдЬ рдХी рдкोрд╕्рдЯ рдоें рдоैं рдПрдХ рдЬाрд╡ा рдк्рд░ोрдЧ्рд░ाрдо рд▓िрдЦрдиे рдЬा рд░рд╣ा рд╣ूँ рдЬो рдЖрдкрдХी рджुрдХाрди рдпा рдХिрд╕ी рдЕрди्рдп рдЙрдж्рджेрд╢्рдп рд╕े рдЗрдирд╡ॉрдЗрд╕ рдЬेрдирд░ेрдЯ рдХрд░ेрдЧा। рдЗрд╕рдХे рдЕрд▓ाрд╡ा, рдоैं рдХाрд░्рдпрдХ्рд░рдо рдХी рд╡्рдпाрдЦ्рдпा рдХрд░рдиे рдЬा рд░рд╣ा рд╣ूं рдФрд░ рдПрдХ рд╡ीрдбिрдпो рдж्рд╡ाрд░ा рдПрдХ рдбेрдоो рджिрдЦाрдКंрдЧा।
What is invoice?
Importance of invoices
- These bills helps to maintain the accounting properly.
- They help us to maintain the budget.
- They help us to remember the rate of any product or service.
- Bills also help us at the time of paying tax.
What is invoice in hindi?
рдЬрдм рдЖрдк рдХिрд╕ी рдХो рдХुрдЫ рдмेрдЪрддे рд╣ैं рдпा рдХिрд╕ी рдХो рдХुрдЫ рднी рд╕ेрд╡ा рдк्рд░рджाрди рдХрд░рддे рд╣ैं рддो рдЖрдкрдХो рдЙрд╕े рдПрдХ рдЙрдЪिрдд рдмिрд▓ рджेрдиा рд╣ोрдЧा।
рдЗрди рдмिрд▓ों рдХो рдЪाрд▓ाрди рдХे рд░ूрдк рдоें рднी рдЬाрдиा рдЬाрддा рд╣ै।
Importance of invoices in hindi
- рдпे рдмिрд▓ рд▓ेрдЦांрдХрди рдХो рдаीрдХ рд╕े рдмрдиाрдП рд░рдЦрдиे рдоें рдорджрдж рдХрд░рддे рд╣ैं।
- рд╡े рд╣рдоें рдмрдЬрдЯ рдмрдиाрдП рд░рдЦрдиे рдоें рдорджрдж рдХрд░рддे рд╣ैं।
- рд╡े рд╣рдоें рдХिрд╕ी рднी рдЙрдд्рдкाрдж рдпा рд╕ेрд╡ा рдХी рджрд░ рдпाрдж рд░рдЦрдиे рдоें рдорджрдж рдХрд░рддे рд╣ैं।
- рдЯैрдХ्рд╕ рдЪुрдХाрддे рд╕рдордп рднी рдмिрд▓ рд╣рдоाрд░ी рдорджрдж рдХрд░рддे рд╣ैं।
Invoice generator java program
import java.io.*;
class Game
{
String np;
float p1;
int q;
float qp;
static float t;
Game(String a, float b, int c, float d)
{
np=a;
p1=b;
q=c;
qp=d;
}
void displayData()
{
System.out.println("Name of product :" +np) ;
System.out.println("Price of 1 unit :"+p1);
System.out.println("Quantity :"+q);
System.out.println("Price of"+q+"units:"+qp);
System.out.println("-------------------------------") ;
t=t+qp;
}
static void total()
{
System.out.println("Grand Total "+t);
}
}
// Compiler version JDK 11.0.2
class Invoice
{
public static void main (String args [] ) throws IOException
{
BufferedReader br = new BufferedReader (new InputStreamReader (System.in));
System.out.println ("Enter Shop name");
String sobn = br.readLine();
System.out.println ("Enter Seller name");
String sn = br.readLine();
System.out.println ("Enter Seller mob no.");
long smn = Long.parseLong (br.readLine ());
System.out.println("Enter buyer name");
String bn = br.readLine();
System.out.println("Enter Buyer mob no.");
long bmn = Long.parseLong ( br.readLine());
System.out.println("Enter no. of Products");
int n = Integer.parseInt (br.readLine());
Game arr[] = new Game [n];
for( int i=0; i<n; i++)
{
System.out.println ("Enter name of "+(i+1)+" product");
String np = br.readLine ( );
System.out.println ("Price of 1 unit");
float p1= Float.parseFloat (br.readLine());
System.out.println ("Quantity");
int q = Integer.parseInt (br.readLine ( ) );
float qp = p1*q;
arr[i] = new Game(np, p1, q, qp);
}
System.out.println(" "+sobn+" ");
System.out.println("___________________");
System.out.print(" Seller name:"+sn+"\t");
System.out.println("\tMob no. :"+smn) ;
System.out.print("Buyer name :"+bn) ;
System.out.println("\tMob no. :"+bmn) ;
System.out.println("____________________") ;
System.out.println("Number of products :"+n) ;
System.out.println("---------------------------------") ;
for(int i = 0; i<arr.length; i++)
{
arr[i].displayData();
}
Game.total();
}
}
Explanation of java program in hindi
- рдЗрд╕ рдк्рд░ोрдЧ्рд░ाрдо рдХी рдкрд╣рд▓ी рд▓ाрдЗрди рдоें рдоैंрдиे java.io рдкैрдХेрдЬ рдХो рдЗрдордкोрд░्рдЯ рдХिрдпा рд╣ै। рдЗрд╕ рдкैрдХेрдЬ рдХी рдорджрдж рд╕े рд╣рдо рдХिрд╕ी рднी рдлाрдЗрд▓ рдХो рдЗंрдкोрд░्рдЯ рдХрд░ा рд╕рдХрддे рд╣ैं рдпा рдЙрд╕े рдЖрдЙрдЯрдкुрдЯ рдХे рдж्рд╡ाрд░ा рд╕ेрд╡ рдХрд░ рд╕рдХрддे рд╣ैं, рд▓ेрдХिрди рдЗрд╕ рдк्рд░ोрдЧ्рд░ाрдо рдоें рд╣рдо рдЗрд╕рдХा рдЙрдкрдпोрдЧ keyboard рд╕े рдЗрдирдкुрдЯ рд▓ेрдиे рдХे рд▓िрдП рдХрд░ेंрдЧे।
- рдЗрд╕рдХे рдмाрдж рдПрдХ рдХ्рд▓ाрд╕ рдмрдиाрдИ рд╣ै рдЬिрд╕рдХो рдиाрдо рджिрдпा рд╣ै рдЧेрдо рдФрд░ рдЗрд╕ рдХ्рд▓ाрд╕ рдоें рд╣рдордиे рддीрди рдк्рд░рдХाрд░ рдХे рдЕрд▓рдЧ-рдЕрд▓рдЧ variable рдмрдиाрдИ।
- рдЗрд╕рдХे рдмाрдж рд╣рдордиे рдПрдХ рдоेрдердб рдмрдиाрдпा рд╣ै, рдЗрд╕рдХो рдиाрдо рджिрдпा рд╣ै рдбिрд╕्рдкрд▓े рдбाрдЯा рдЗрд╕ рдоेрдердб рдХे рдЕंрджрд░ рд╣рдордиे рд╕рдмрд╕े рдкрд╣рд▓े рдк्рд░ोрдбрдХ्рдЯ рдХा рдиाрдо рдк्рд░िंрдЯ рдХрд░ рдЖрдпा рд╣ै। рдлिрд░ рдк्рд░ोрдбрдХ्рдЯ рдХी рдХ्рд╡ांрдЯिрдЯी рдлिрд░ рдПрдХ рдпूрдиिрдЯ рдХी рдк्рд░ाрдЗрд╕ рдФрд░ рдЗрд╕рдХे рдмाрдж рд╣рдордиे рдк्рд░ोрдбрдХ्рдЯ рдХी рдЯोрдЯрд▓ рдк्рд░ाрдЗрд╕ рдк्рд░िंрдЯ рдХрд░ рдЖрдИ рд╣ै।
- рдЗрд╕рдХे рдмाрдж рд╣рдордиे рдПрдХ рд╕्рдЯैрдЯिрдХ рдоेрдердб рдмрдиाрдпा рд╣ै рдЬिрд╕рдоें рд╣рдордиे рдЧ्рд░ैंрдб рдЯोрдЯрд▓ рдк्рд░िंрдЯ рдХрд░ाрдпा рд╣ै।
- рдЗрд╕рдХे рдмाрдж рд╣рдордиे рдПрдХ рдФрд░ рдХ्рд▓ाрд╕ рдмрдиाрдИ рд╣ै рдЬिрд╕рдХा рдиाрдо рджिрдпा рд╣ै рдЗрдирд╡ॉрдЗрд╕ рдЬिрд╕рдоें рд╣рдордиे main рдоेрдердб рдмрдиाрдпा рд╣ैं.
- рдЗрд╕ рд▓ाрдЗрди рдХा рдорддрд▓рдм рд╣ै рдХि рд╣рдордиे рдХिрдмोрд░्рдб рдж्рд╡ाрд░ा рдЗрдирдкुрдЯ рд▓िрдпा рд╣ै. рдФрд░ рдЗрди рд╕рднी рдЗрдирдкुрдЯ рдХा рдПрдХ buffer рдмрдиा рд▓िрдпा рд╣ै। рдпрд╣ рдХрджрдо program рдХी рдЧрддि рдХो рдмрдв़ाрддा рд╣ै।
- рдЗрд╕рдХे рдмाрдж рдоें рджुрдХाрди рдХा рдиाрдо, рдмेрдЪрдиे рд╡ाрд▓े рдХा рдиाрдо, рдмेрдЪрдиे рд╡ाрд▓े рдХा рдоोрдмाрдЗрд▓ рдиंрдмрд░, рдЦрд░ीрджрдиे рд╡ाрд▓े рдХा рдиाрдо, рдЦрд░ीрджрдиे рд╡ाрд▓े рдХा рдоोрдмाрдЗрд▓ рдиंрдмрд░, рдФрд░ рдЦрд░ीрджे рдЧрдП рдк्рд░ोрдбрдХ्рдЯ рдХी рд╕ंрдЦ्рдпा рдХा рдХिрдмोрд░्рдб рдж्рд╡ाрд░ा рдЗрдирдкुрдЯ рд▓िрдпा рд╣ै।рдЗрд╕рдХे рдмाрдж рдЬिрддрдиी рдк्рд░ोрдбрдХ्рдЯ рдХी рд╕ंрдЦ्рдпा рд╣ै, рдЙрддрдиी рд╣ी рд╕ाрдЗрдЬ рдХा рдПрдХ array рдмрдиाрдпा рдЧрдпा рд╣ै।
- рдЗрд╕рдХे рдмाрдж рдПрдХ for loop рдмрдиाрдпा рдЧрдпा рд╣ै рдЬो рдк्рд░ोрдбрдХ्рдЯ рдХी рд╕ंрдЦ्рдпा рд╕े рдПрдХ рдмाрд░ рдХрдо рдЪрд▓ेрдЧा।
- рдЗрд╕ loop рдоें рд╣рдордиे рдк्рд░ोрдбрдХ्рдЯ рдХा рдиाрдо, рдк्рд░ोрдбрдХ्рдЯ рдХे рдПрдХ рдпूрдиिрдЯ рдХी рдХीрдордд, рдк्рд░ोрдбрдХ्рдЯ рдХी рд╕ंрдЦ्рдпा, рдФрд░ рдЦрд░ीрджे рдЧрдП рдк्рд░ोрдбрдХ्рдЯ рдХी рдХुрд▓ рдХीрдордд рдХा рдЗрдирдкुрдЯ рд▓िрдпा рд╣ै. рдФрд░ рдЗрди рд╕рднी рдбिрдЯेрд▓्рд╕ рдХो рдмाрд░ी-рдмाрд░ी рдХрд░ array рдоें рд╕्рдЯोрд░ рдХिрдпा рдЧрдпा рд╣ै।
- рдЗрд╕рдХे рдмाрдж рд╣рдордиे рджुрдХाрди рдХा рдиाрдо рдмेрдЪрдиे рд╡ाрд▓े рдХा рдиाрдо рдмेрдЪрдиे рд╡ाрд▓े рдХा рдоोрдмाрдЗрд▓ рдиंрдмрд░ рдЦрд░ीрджрдиे рд╡ाрд▓े рдХा рдиाрдо рдЦрд░ीрджрдиे рд╡ाрд▓े рдХा рдоोрдмाрдЗрд▓ рдиंрдмрд░ рдФрд░ рдЦрд░ीрджी рдХा рдк्рд░ोрдбрдХ्рдЯ рдХी рдХुрд▓ рд╕ंрдЦ्рдпा рдк्рд░िंрдЯ рдХрд░ाрдИ рд╣ै।
- рдЗрд╕рдХे рдмाрдж рдПрдХ рдФрд░ for loop рдмрдиाрдпा рдЧрдпा рд╣ै рдЬिрд╕рдХे рдж्рд╡ाрд░ा array рдоें рд╕्рдЯोрд░ рдбाрдЯा рдХो рдмाрд░ी-рдмाрд░ी рдХрд░ рдбिрд╕्рдкрд▓े рдбाрдЯा рдоेрдердб рдХो рднेрдЬा рдЧрдпा рд╣ै рдФрд░ рдк्рд░िंрдЯ рдХрд░ाрдпा рдЧрдпा рд╣ै।
- рдЗрд╕рдХे рдмाрдж рд╕्рдЯैрдЯिрдХ рдоेрдердб рдЯोрдЯрд▓ рдХो рдмुрд▓ाрдпा рдЧрдпा рд╣ै рдФрд░ рдЧ्рд░ैंрдб рдЯोрдЯрд▓ рдк्рд░िंрдЯ рдХिрдпा рдЧрдпा рд╣ै।
Explanation of java program in english
- In the first line of this program I have imported the java.io package. With the help of this package, we can import any file or save it by output, but in this program we will use it to take input from keyboard.
- After this a class has been created which is named Game and in this class we have created three types of different variables.
- After this we have created a method, it is named display data. Inside this method, we have printed the name of the product first. Then the quantity of the product then the price of a unit And after that we have printed the total price of the product.
- After this we have created a static method in which we have printed the grand total.
- After this we have created another class named Invoice in which we have created main method.
- This line means that we have taken input from keyboard. and created a buffer of all these inputs. This step increases the speed of program.
- After this, the name of the shop, the name of the seller, the mobile number of the seller, the name of the buyer, the mobile number of the buyer, and the number of the product purchased are input from the keyboard.After this, an array of the same size is made as the number of products.
- After this a for loop is created which will run once less than the number of products.
- In this loop, we have taken the input of the name of the product, the price of a unit of the product, the number of the product, and the total cost of the product purchased. And all these details are stored in the array in turn.
- After this we have printed the name of the shop, the name of the seller, the mobile number of the seller, the name of the buyer, the mobile number of the buyer and the total number of the product purchased.
- After this another for loop is created through which the data stored in the array is alternately sent to the display data method and printed.
- After this the static method total is called and the grand total is printed.
Video demo
This short video will show you a demo how this program works and how it will generate an invoice ?
рдпрд╣ рд▓рдШु рд╡ीрдбिрдпो рдЖрдкрдХो рдПрдХ рдбेрдоो рджिрдЦाрдПрдЧा рдХि рдпрд╣ рдк्рд░ोрдЧ्рд░ाрдо рдХैрд╕े рдХाрдо рдХрд░рддा рд╣ै рдФрд░ рдпрд╣ рдПрдХ рдЪाрд▓ाрди рдХैрд╕े рдЙрдд्рдкрди्рди рдХрд░ेрдЧा?

No comments: