Search the Whole World Here.,.,

Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts

Net Payable Amount (GUI) - JAVA Project

Code to add under jButton1


private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

        //We will add the function.

        double price = Double.parseDouble(jTextField1.getText());
        double qty = Double.parseDouble(jTextField2.getText());             //double is used for values in points.
     
        double salAmt = price * qty;
        double disc = salAmt * 0.10;
        double netAmt = salAmt - disc;
     
        jTextField3.setText(" "+salAmt);
        jTextField4.setText(" "+disc);
        jTextField5.setText(" "+netAmt);        //Shortcut key used is SHIFT + DOWN ARROW.
    }




These Are The Fastest Growing Programming Languages


A lot of new programming languages are making their way to the top and JavaScript is holding the top position for the past few years. Seems like the situation is about to change and JavaScript may soon be dethroned by Python. Python is one of the fastest growing languages and by 2019, it would have a clear domination in the programming community.
This is a prediction made by Stack Overflow, a programming Q&A center. With more than 50 million amateur and professional developers visiting the website, Stack Overflow is one of the qualified companies to make such a survey. Based on the huge increase in the questions from developers on Python and the data they have collected, Stack Overflow made this survey possible.
Stack Overflow data scientist David Robinson said in a blog post that, “The term ‘fastest-growing’ can be really hard to define precisely, but we make the case that Python has a solid claim to become the fastest-growing major programming language.

  
Just in the past five years, Python went from least to top six most popular programming languages with a whopping 2.5x increase in the questions and views on the language. Stack Overflow also stated that these statistics are related to developers from countries with “high-income”  and represent the trend in the United States, United Kingdom, Canada, Germany and other such countries.
The secret behind the growth of Python is its flexibility and versatility. Python is generally used by web and desktop developers, develops/sysadmin and recently even data scientists and machine-learning with Python became popular.
“It seems like Python is used in every domain — system operations, web development, deployment, scientific modeling, etc etc. There is no other language that is so versatile,” says Jacqueline Kazil, board director of the Python Software Foundation (PSF).








4 Essential Tools for a Java-Centric IT Environment


For those unfamiliar with the modern IT scene, “java” might still conjure up images of coffee mugs filled to the brim. And while that is an essential tool for all IT specialists who work the morning shift, we use “Java” here in reference to the popular programming language originally developed by James Gosling back in 1995 (centuries ago in “IT years!”).
Java, a widely used programming language, is designed for use in the distributed environment of the internet. It is the most popular programming language for Android smartphone applications and for the Internet of Things development.
Java is now used by some 9 million software developers and is especially popular with client-server Web apps. Its flexibility and compatibility with every computer architecture and its inherent simplicity and “smartness” have endeared it to the hearts of millions.


Assuring meticulous performance can be challenging without the right tools. That’s why every Java developer, performance tuner, and end-user needs to be equipped with those tools to ensure the best possible results, including these four:


1. The Best, Most Appropriate Java Profiler

Java profilers can help you with a multitude of programming tasks, including memory usage monitoring, memory leak detection, analyzing method call durations, finding performance bottlenecks, resolving threading problems, displaying helpful graphs and reports, and much more.

2. Bug Finding Tools

To help Java software developers write better code, nothing is more important than an effective, efficient bug finder, like for example FindBugs. FindBugs is an open source tool that utilizes Java bytecode instead of source code. It employs “static analysis” to quickly find numerous types of errors that may be gotten into your Java program.
And besides identifying the exact type of error and its location, FindBugs also gives you an entertaining but still helpful analysis of the severity level of each error: of concern, troubling, scary, and scariest.
  


3. Auto-build Tools

Given the complexity and length of coding structures in modern Java (and other) software, it is essential to avail yourself of an auto-build tool like Apache Ant to speed things up. Apache Ant is open source, uses XML, and uses Javascript.
In fact, “the ant” actually requires a Java platform and is mostly utilized for Java-based software projects. However, you can also use it for non-Java apps, like with C/C++.
Apache Ant is very flexible and non-restrictive as to coding conventions/layouts, and it will help you to quickly and easily assemble and test-run your Java apps to ensure they are all you want them to be.



4. Data Leakage Protection Software

No matter how careful one is in programming with Java and pre-testing it, in these days of cloud-based data storage, data leaks are much more dangerous than they once were. If files fall into the wrong hands or simply get “lost,” the consequences to companies can be serious indeed as trade secrets are exposed and consumer confidence is shaken. Data leakage protection software can greatly increase the security level of online data that you simply can’t afford to see compromised.

Q2. Consider the following code snippet:

Q2. Consider the following code snippet:


int number = 14;

if (number >= 10;

{      

    if (number  == 10)         

                jLabel1.setText("first string");      

    else               

               jLabel1.setText("second string");    

                 jLabel2.setText("third string");

}


What will be the output of the following code snippet:

Q1.  Identify the error(s) in the following code  fragment

Q1. Identify the error(s) in the following code fragment



switch(ch)
{
    case 'a':
    case 'A':
    case 'e':
    case 'E':
    case 'i':
    case 'i':
    break;
 
    default :  ch = 'N';
    break;
}


Comment your answers fast......
Give me your answers.....


In the above code fragment errors are:

i)  The variable ch is uninitialised.
ii) The switch statements two case constants are
     identical : case 'i' and case 'i'.
     The case constant must have different value.

School Management System - Project Download Free


Project of School Management for Class XII - IP Download from here :


ScreenShots


StartUp Form



SignUp Form


This Project is fully designed in Netbeans IDE 6.5 by Abhishek Gupta.,.,.,.,
If you want to see full screenshots of the project with database then click on the below link.,.,.,



Download this project from here

If you like the project them follow the blog for more similar projects.




NetBeans เค†เคˆเคกเฅ€เคˆ เคฎเฅ‡เค‚ ProgressBar เค•เคพ เค‰เคชเคฏเฅ‹เค— เค•เฅˆเคธเฅ‡ เค•เคฐเฅ‡เค‚

NetBeans เค†เคˆเคกीเคˆ เคฎें ProgressBar เค•ा เค‰เคชเคฏोเค— เค•ैเคธे เค•เคฐें

เคจเคฎเคธ्เค•ाเคฐ เคฆोเคธ्เคคों !

เคฎैं เค•े เคฐूเคช เคฎें เคฎैं เคตเคฐ्เคคเคฎाเคจ เคฎें เคเค• เคชเคฐिเคฏोเคœเคจा เคนै เคœिเคธเคฎें เคฎैं NewJFrame เคซाเคฐ्เคฎ เค•ो เคธ्เคฅाเคจांเคคเคฐिเคค เค•เคฐเคจे เค•े เคฒिเค ProgressBar เค‰เคชเคฏोเค— เค•เคฐเคจा เคšाเคนเคคे เคนैं เคชเคฐ เค•ाเคฎ เค•เคฐ เคฐเคนा เคนूँ เค†เคชเค•ी เคฎเคฆเคฆ เค•ी เคœเคฐूเคฐเคค เคนै।

เคŸिเคช्เคชเคฃी เคฌॉเค•्เคธ เคฎें เค•ोเคกिंเค— เคŸिเคช्เคชเคฃी เค•เคฐें।

เค†เคชเค•ो เคงเคจ्เคฏเคตाเคฆ

เคธाเคฆเคฐ

เคฏाเคฐ เค•ोเคˆ เคช्เคฐौเคฆ्เคฏोเค—िเค•ी

How do I convert string to an integer or number?

How do I convert string to an integer or number?

package org.kodejava.example.lang;
public class StringToInteger {
public static void main(String[] args) {

// Some random selected number, could representing a decimal,
// hexadecimal or octal number.

String myLuckyNumber = "13";

// We convert a string to an integer by invoking parseInt() method
// of the Integer class.

Integer number = Integer.parseInt(myLuckyNumber);
System.out.println("My lucky number is: " + number);

// We can also converting a string representation of a number other
// then the decimal base, for instance an hexadecimal by providing
// the radix to the method.

number = Integer.parseInt(myLuckyNumber, 16);
System.out.println("My lucky number is: " + number);
number = Integer.parseInt(myLuckyNumber, 8);
System.out.println("My lucky number is: " + number);
}
}

Our code results are:

My lucky number is: 13
My lucky number is: 19
My lucky number is: 11


Source : https://kodejava.org/how-do-i-convert-string-to-an-integer-or-number/
How do I reverse a string?

How do I reverse a string?

Below is an example code that reverse a string. In this example we useStringBuffer.reverse() method to reverse a string. In Java 1.5, a new class calledStringBuilder also has a reverse() method that do just the same, one of the difference is StringBuffer class is synchronized while StringBuilder class is not.
And here is the string reverse in the StringBuffer way.
package org.kodejava.example.lang;

public class StringReverseExample {
    public static void main(String[] args) {
        // The normal sentence that is going to be reversed.
        String words =
                "Morning of The World - The Last Paradise on Earth";

        // To reverse the string we can use the reverse() method in
        // the StringBuffer class. The reverse() method returns a
        // StringBuffer so we need to call the toString() method to
        // get a string object.
        String reverse = new StringBuffer(words).reverse().toString();

        // Print the normal string
        System.out.println("Normal : " + words);
        // Print the string in reversed order
        System.out.println("Reverse: " + reverse);
    }
}
Beside using this simple method you can try to reverse a string by converting it to character array and then reverse the array order.
And below is the result of the code snippet above.
Normal : Morning of The World - The Last Paradise on Earth
Reverse: htraE no esidaraP tsaL ehT - dlroW ehT fo gninroM

Source : https://kodejava.org/how-do-i-reverse-a-string/

How do I iterate each characters of a string?

How do I iterate each characters of a string?

package org.kodejava.example.text; import java.text.CharacterIterator; import java.text.StringCharacterIterator; public class StringCharacterIteratorExample { private static final String text = "The quick brown fox jumps over the lazy dog"; public static void main(String[] args) { CharacterIterator it = new StringCharacterIterator(text); int vowels = 0; int consonants = 0; // Iterates charater sets from the beginning to the last character for (char ch = it.first(); ch != CharacterIterator.DONE; ch = it.next()) { if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u') { vowels = vowels + 1; } else if (ch != ' ') { consonants = consonants + 1; } } System.out.println("Number of vowels: " + vowels); System.out.println("Number of consonants: " + consonants); } }




Source :https://kodejava.org/how-do-i-iterate-each-characters-of-a-string/
How do I add leading zeros to a number?

How do I add leading zeros to a number?

This example shows you how to use the String.format() method to add zero padding to a number. If you just want to print out the result you can use System.out.format(). This method is available since Java 1.5, so If you use a previous version you can use the NumberFormat class, see: How do I format a number with leading zeros?.


package org.kodejava.example.lang; public class LeadingZerosExample { public static void main(String[] args) { int number = 1500; // // String format below will add leading zeros (the %0 syntax) // to the number above. The length of the formatted string will // be 7 characters. // String formatted = String.format("%07d", number); System.out.println("Number with leading zeros: " + formatted); } }


Here is the result of the code snippet above:

Number with leading zeros: 0001500

Source : https://kodejava.org/how-do-i-add-leading-zeros-to-a-number/
How do I convert InputStream to String?

How do I convert InputStream to String?

This example will show you how to convert an InputStream into String. In the code snippet below we read a data.txt file, could be from common folder or from inside a jar file.


package org.kodejava.example.io; import java.io.*; public class StreamToString { public static void main(String[] args) throws Exception { StreamToString sts = new StreamToString(); // Get input stream of our data file. This file can be in // the root of you application folder or inside a jar file // if the program is packed as a jar. InputStream is = sts.getClass().getResourceAsStream("/data.txt"); // Call the method to convert the stream to string System.out.println(sts.convertStreamToString(is)); } public String convertStreamToString(InputStream is) throws IOException { // To convert the InputStream to String we use the // Reader.read(char[] buffer) method. We iterate until the // Reader return -1 which means there's no more data to // read. We use the StringWriter class to produce the string. if (is != null) { Writer writer = new StringWriter(); char[] buffer = new char[1024]; try { Reader reader = new BufferedReader( new InputStreamReader(is, "UTF-8")); int n; while ((n = reader.read(buffer)) != -1) { writer.write(buffer, 0, n); } } finally { is.close(); } return writer.toString(); } return ""; } }



Source : https://kodejava.org/how-do-i-convert-inputstream-to-string/
WordCount

WordCount

Program  that compares counting words in files using an ArrayList and a Map.


import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Scanner;

import javax.swing.JFileChooser;
import javax.swing.UIManager;


public class WordCount {

    public static void main(String[] args) {
        countWordsViaGUI();
    }


    // allow user to pick file to exam via GUI.
    // allow multiple picks
    public static void countWordsViaGUI() {
        setLookAndFeel();
        try {
            Scanner key = new Scanner(System.in);
            do {
                System.out.println("Opening GUI to choose file.");
                Scanner fileScanner = new Scanner(getFile());
                Stopwatch st = new Stopwatch();
                st.start();
                ArrayList words = countWordsWithArrayList(fileScanner);
                st.stop();
                System.out.println("time to count: " + st);
                System.out.print("Enter number of words to display: ");
                int numWordsToShow = Integer.parseInt(key.nextLine());
                showWords(words, numWordsToShow);
                fileScanner.close();
                System.out.print("Perform another count? ");
            } while(key.nextLine().toLowerCase().charAt(0) == 'y');
            key.close();
        }
        catch(FileNotFoundException e) {
            System.out.println("Problem reading the data file. Exiting the program." + e);
        }
    }


    // determine distinct words in a file using an array list
    private static ArrayList countWordsWithArrayList(Scanner fileScanner) {


        System.out.println("Total number of words: " + numWords);
        System.out.println("number of distincy words: " + result.size());
        return result;
    }


    // determine distinct words in a file and frequency of each word with a Map
    private static Map countWordsWithMap(Scanner fileScanner) {


        System.out.println("Total number of words: " + numWords);
        System.out.println("number of distincy words: " + result.size());
        return result;
    }


    private static void showWords(ArrayList words, int numWordsToShow) {
        for(int i = 0; i < words.size() && i < numWordsToShow; i++)
            System.out.println(words.get(i));
    }


    private static void showWords(Map words, int numWordsToShow) {



    }


    // perform a series of experiments on files. Determine average time to
    // count words in files of various sizes
    private static void performExp() {
        String[] smallerWorks = {"smallWords.txt", "2BR02B.txt", "Alice.txt", "SherlockHolmes.txt"};;
        String[] bigFile = {"ciaFactBook2008.txt"};
        timingExpWithArrayList(smallerWorks, 50);
        timingExpWithArrayList(bigFile, 3);
        timingExpWithMap(smallerWorks, 50);
        timingExpWithMap(bigFile, 3);
    }


    // pre: titles != null, elements of titles refer to files in the
    // same path as this program, numExp >= 0
    // read words from files and print average time to cound words.
    private static void timingExpWithMap(String[] titles, int numExp) {
        try {
            double[] times = new double[titles.length];
            final int NUM_EXP = 50;
            for(int i = 0; i < NUM_EXP; i++) {
                for(int j = 0; j < titles.length; j++) {
                    Scanner fileScanner = new Scanner(new File(titles[j]));
                    Stopwatch st = new Stopwatch();
                    st.start();
                    Map words = countWordsWithMap(fileScanner);
                    st.stop();
                    System.out.println(words.size());
                    times[j] += st.time();
                    fileScanner.close();
                }
            }
            for(double a : times)
                System.out.println(a / NUM_EXP);
        }
        catch(FileNotFoundException e) {
            System.out.println("Problem reading the data file. Exiting the program." + e);
        }
    }


    // pre: titles != null, elements of titles refer to files in the
    // same path as this program, numExp >= 0
    // read words from files and print average time to cound words.
    private static void timingExpWithArrayList(String[] titles, int numExp) {
        try {
            double[] times = new double[titles.length];
            for(int i = 0; i < numExp; i++) {
                for(int j = 0; j < titles.length; j++) {
                    Scanner fileScanner = new Scanner(new File(titles[j]));
                    Stopwatch st = new Stopwatch();
                    st.start();
                    ArrayList words = countWordsWithArrayList(fileScanner);
                    st.stop();
                    times[j] += st.time();
                    fileScanner.close();
                }
            }
            for(int i = 0; i < titles.length; i++)
                System.out.println("Average time for " + titles[i] + ": " + (times[i] / numExp));
        }
        catch(FileNotFoundException e) {
            System.out.println("Problem reading the data file. Exiting the program." + e);
        }
    }


    // try to set look and feel to same as system
    private static void setLookAndFeel() {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        }
        catch(Exception e) {
            System.out.println("Unable to set look at feel to local settings. " +
            "Continuing with default Java look and feel.");
        }
    }


    /** Method to choose a file using a window.
     * @return the file chosen by the user. Returns null if no file picked.
     */
    private static File getFile() {
        // create a GUI window to pick the text to evaluate
        JFileChooser chooser = new JFileChooser(".");
        chooser.setDialogTitle("Select File To Count Words:");
        int retval = chooser.showOpenDialog(null);
        File f =null;
        chooser.grabFocus();
        if (retval == JFileChooser.APPROVE_OPTION)
            f = chooser.getSelectedFile();
        return f;
    }
}


Ads by Google