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? 

    The other meaning of invoice is receipt. 
    When you sell something to anyone or provide service of anything to anybody then you have to give him a proper bill.
    These bills are also known as invoices. 

    Importance of invoices


    1. These bills helps to maintain the accounting properly.
    2. They help us to maintain the budget. 
    3. They help us to remember the rate of any product or service. 
    4. Bills also help us at the time of paying tax.

    What is invoice in hindi? 

    चालान का दूसरा अर्थ रसीद है। 

    जब आप किसी को कुछ बेचते हैं या किसी को कुछ भी सेवा प्रदान करते हैं तो आपको उसे एक उचित बिल देना होगा।

    इन बिलों को चालान के रूप में भी जाना जाता है।

    Importance of invoices in hindi

    1. ये बिल लेखांकन को ठीक से बनाए रखने में मदद करते हैं। 
    2. वे हमें बजट बनाए रखने में मदद करते हैं।
    3. वे हमें किसी भी उत्पाद या सेवा की दर याद रखने में मदद करते हैं।
    4. टैक्स चुकाते समय भी बिल हमारी मदद करते हैं।

    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

    1. इस प्रोग्राम की पहली लाइन में मैंने java.io पैकेज को इमपोर्ट किया है। इस पैकेज की मदद से हम किसी भी फाइल को इंपोर्ट करा सकते हैं या उसे आउटपुट के द्वारा सेव कर सकते हैं, लेकिन इस प्रोग्राम में हम इसका उपयोग keyboard से इनपुट लेने के लिए करेंगे। 
    2. इसके बाद एक क्लास बनाई है जिसको नाम दिया है गेम और इस क्लास में हमने तीन प्रकार के अलग-अलग variable बनाई।
    3. इसके बाद हमने एक मेथड बनाया है, इसको नाम दिया है डिस्पले डाटा इस मेथड के अंदर हमने सबसे पहले प्रोडक्ट का नाम प्रिंट कर आया है। फिर प्रोडक्ट की क्वांटिटी फिर एक यूनिट की प्राइस और इसके बाद हमने प्रोडक्ट की टोटल प्राइस प्रिंट कर आई है।
    4. इसके बाद हमने एक स्टैटिक मेथड बनाया है जिसमें हमने ग्रैंड टोटल प्रिंट कराया है। 
    5. इसके बाद हमने एक और क्लास बनाई है जिसका नाम दिया है इनवॉइस जिसमें हमने main मेथड बनाया हैं. 
    6. इस लाइन का मतलब है कि हमने किबोर्ड द्वारा इनपुट लिया है. और इन सभी इनपुट का एक buffer बना लिया है। यह कदम program की गति को बढ़ाता है।
    7. इसके बाद में दुकान का नाम, बेचने वाले का नाम, बेचने वाले का मोबाइल नंबर, खरीदने वाले का नाम, खरीदने वाले का मोबाइल नंबर, और खरीदे गए प्रोडक्ट की संख्या का किबोर्ड द्वारा इनपुट लिया है।इसके बाद जितनी प्रोडक्ट की संख्या है, उतनी ही साइज का एक array बनाया गया है।
    8. इसके बाद एक for loop बनाया गया है जो प्रोडक्ट की संख्या से एक बार कम चलेगा।
    9. इस loop में हमने प्रोडक्ट का नाम, प्रोडक्ट के एक यूनिट की कीमत, प्रोडक्ट की संख्या, और खरीदे गए प्रोडक्ट की कुल कीमत का इनपुट लिया है. और इन सभी डिटेल्स को बारी-बारी कर array में स्टोर किया गया है।
    10. इसके बाद हमने दुकान का नाम बेचने वाले का नाम बेचने वाले का मोबाइल नंबर खरीदने वाले का नाम खरीदने वाले का मोबाइल नंबर और खरीदी का प्रोडक्ट की कुल संख्या प्रिंट कराई है।
    11. इसके बाद एक और for loop बनाया गया है जिसके द्वारा array में स्टोर डाटा को बारी-बारी कर डिस्पले डाटा मेथड को भेजा गया है और प्रिंट कराया गया है।
    12. इसके बाद स्टैटिक मेथड टोटल को बुलाया गया है और ग्रैंड टोटल प्रिंट किया गया है।
     

    Explanation of java program in english


    1. 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. 
    2. After this a class has been created which is named Game and in this class we have created three types of different variables.
    3. 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. 
    4. After this we have created a static method in which we have printed the grand total.
    5. After this we have created another class named Invoice in which we have created main method. 
    6. 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. 
    7. 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.
    8. After this a for loop is created which will run once less than the number of products.
    9. 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.
    10. 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.
    11. 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.
    12. 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:

    Powered by Blogger.