Saturday 31 December 2011

Truth of Earth in 2012

It is just a fable that earth will meet its end on 21st December 2012. There is no possibility of earth meeting its catastrophe. There is no planetary or asteroidal movements that can strike the earth in future years. This is the day of winter solstice. This favle actually rose from fact that Sumerians discovered a planet that would have struck in May 2003 and this day was forwarded to 2012. But all this are baseless. NASA is regularly observing planetary movements. All this were actually connected with the fact that ancient Mayan Calendar will end in 2012. But this just like 1st January after 31st December, so next long count of Mayan Calendar will begin after 2012. Even the fact of polar shift is also baseless. This is because it is never possible for Earth to rotate in the reverse direction.

To know more Click here to go to NASA website

Monday 26 December 2011

Encryption Software with Java

This software is used for encrypting or decrypting a file with and without password. Files encrypted with this software cannot be decrypted with others or others with this one because of difference in keys.
Requirements : Java Run Time Environment must be installed on your computer.

Click to DOWNLOAD the software version 1.0 from 4shared.com
Click to DOWNLOAD Encrypter Version 2.0 from 4shared.com

Java program to encrypt/decrypt a file with password

Java can be very efficiently in encrypting files in DES mode. In order to encrypt any text or file , first it is necessary to generate a particular key that will be used for encryption.This key is generated based on password. The parameter used is "PBEWithMD5andDES". Then generally a 8 bit salt is created from it. This salt must be written to the file first as it will be required for decryption of the file later. Next we have to create a Cipher object with the particular mode of encryption as its parameter. Then the Cipher object is initialized with the key and either ENCRYPT_MODE or DECRYPT_MODE . After all this is done, we just need to read a stream of bytes from a particular file using FileInputStream and encrypt it and then write to another file using FileOutputStream.
NOTE : The same key must be used for encrypting and decrypting the same file.
Code Extracts :
PBEKeySpec keySpec = new PBEKeySpec(password.toCharArray());
SecretKeyFactory keyFactory=SecretKeyFactory.getInstance("PBEWithMD5AndDES");
SecretKey passwordKey = keyFactory.generateSecret(keySpec); //key from password
byte[] salt = new byte[8];
Random rnd = new Random();
rnd.nextBytes(salt); //getting salt
int iterations = 100;
PBEParameterSpec parameterSpec = new PBEParameterSpec(salt, iterations);
Cipher cipher = Cipher.getInstance("PBEWithMD5AndDES"); //cipher instance
cipher.init(Cipher.ENCRYPT_MODE, passwordKey, parameterSpec); //initializing instance

Click to DOWNLOAD the JAVA file of password based encrypter from 4shared.com
Click to DOWNLOAD the JAVA file of password based decrypter from 4shared.com

Saturday 24 December 2011

C program to create a 15 puzzle game

This game is a very simple one just a replica of the GUI version developed through Java programming. This game works with keys "w","a","s","d" for moving the blank box up, left, down, right respectively.


Click to DOWNLOAD the C source file from 4shared.com

Java program to encrypt or decrypt a file in DES mode

Java can be very efficiently in encrypting files in DES mode. In order to encrypt any text or file , first it is necessary to generate a particular key that will be used for encryption. Next we have to create a Cipher object with the particular mode of encryption as its parameter. Then the Cipher object is initialized with the key and either ENCRYPT_MODE or DECRYPT_MODE . After all this is done, we just need to read a stream of bytes from a particular file using FileInputStream and encrypt it and then write to another file using FileOutputStream.
NOTE : The same key must be used for encrypting and decrypting the same file.
Code Extracts :
byte key[] = "klHGtyCD".getBytes(); //setting my own key
SecretKeySpec secretKey = new SecretKeySpec(key,"DES"); //key generated
Cipher encrypt=Cipher.getInstance("DES/ECB/PKCS5Padding"); //cipher object
encrypt.init(Cipher.ENCRYPT_MODE, secretKey); //initializing object


Click to DOWNLOAD the JAVA file of Encrypter from 4shared.com
Click to DOWNLOAD the JAVA file of Decrypter from 4shared.com

Thursday 22 December 2011

Java Program to perform Radix Sort

Radix Sort is a type of bucket sort. This type of sort is based on radix i.e. 10 for decimal numbers and 26 for alphabets. This technique is very useful in sorting words alphabetically. Arrays are sorted in a total of "d" passes where "d" is the number of digits of highest number..
For decimal numbers : In first pass array is sorted according to units digit , then in next pass sorted according to tens digit and so on.This process goes on till all the digits of highest numbers are traversed.
For words : In first pass array is sorted according to first letter , and in second pass second character is considered and so on.
Here is the code for you -->

import java.io.*;
public class Radix_Sort {

    public void sort(int a[],int rad,int max){
        int tmp[][]=new int[a.length][10];

        for(int i=0;i<max;i++){

            int c=0;
            for (int j=0;j<a.length;j++)
                for(int k=0;k<rad;k++)
                    tmp[j][k]=0;

            for(int k=0;k<a.length;k++){
                int d=(int)((a[k]/Math.pow(10,i))%10);
                tmp[k][d]=a[k];
            }

            for (int j=0;j<rad;j++)
                for(int k=0;k<a.length;k++)
                    if(tmp[k][j]!=0)
                        a[c++]=tmp[k][j];
        }

        disp(a);
    }

    public void input()throws Exception{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        System.out.print("Enter array size : ");
        int n=Integer.parseInt(br.readLine());
        int a[]=new int[n];
        System.out.println("Enter elements in array ------->");
        int max=0;
        for (int i = 0; i<n; i++) {
            System.out.print("Enter number : ");
            a[i]=Integer.parseInt(br.readLine());
            if(a[i]>max)
                max=a[i];
        }
        sort(a,10,digit_count(max));
     }

    int digit_count(int n){
        int d=0;
        while (n!=0) {
            d++;
            n/=10;
        }
        return d;
    }

    public void disp(int a[]){
        System.out.println("\nArray after sorting -------->");
        for (int i = 0; i<a.length; i++)
            System.out.print(a[i]+"  ");
    }

    public static void main(String[] args) throws Exception{
        new Radix_Sort().input();
    }
}


You can also download the source from below links :
DOWNLOAD source JAVA file from MediaFire
DOWNLOAD the JAVA file from 4shared

Wednesday 7 December 2011

New Planet Kepler 22B - Earth Like Discovered

NASA has discovered a Earth like planet named Kepler 22B in our Universe. The Kepler mission was started in the year 2007 and will end in 2012. During this period NASA has come across many stars and planets. From this some were seperated and were similar to our planet and were called candidates. Among this Kepler 22B is one which is almost like Earth's twin revolving around a star like our Sun. It is about 600 light years away from our planet. Kepler 22B is at a 15% distance less than what our Earth is from Sun. The average temperature is about 22C . This planet also has liquid water. Considering all this facts scientists has claimed that this is an ideal planet for habitat. But they are not yet sure whether it is a gaseous or a rocky planet. They are investigating on existence of life which has been yhe question of almost every scientists when Earth is facing its end due to human actions.

Click here to know more news from NASA

Monday 21 November 2011

Living organism traced in Dead Sea

Dead Sea of Israel is the most saline sea. Here everything floats on here. Due to extreme salinity it is impossible for any organism to stay alive here. But the scientists of Max Planck Institute have collected samples of certain bacteria that are present in Dead Sea. They are now wondering about that how it is possible for the bacteria to stay alive. Research is now going on to find out the reason behind it.

Friday 18 November 2011

Java program to create a music pattern

This program is done using Java Swing to create the GUI pattern. The music pattern is developed using Java MIDI Sequemce. The user can create different music pattern by clicking related check boxes.The user can also change the tempo factor.

Click to DOWNLOAD the archive from 4shared.com

Java program to design a GUI based 15 puzzle game

It is simply a game of arranging numbers 1-15 which are placed in a 4*4 2D array with one block left blank. One will have to arrange by moving the blank block. Here a timer is included to count total time to solve it. This logic is given a GUI with help of Java Swing.Here is the code for you -->
The Screenshot shown alongside is actually the picture how the game will look like when run on Windows7. It will look same as to the code of JAVA file link given below but different from the below code only in respect with game menubar. Try writing below code and also that is written in file (link given at last). Hope you will enjoy.

import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import java.text.*;

public class FifteenPuzzle2 extends JPanel {
  public static JMenuItem newItem;
  public static javax.swing.Timer t;
  JButton[][] jb = new JButton[4][4];
  static int minute, second;
  static JFrame jf;

  public FifteenPuzzle2() {
       setLayout(new GridLayout(4, 4));

       int i, j, k;
       init(true);
       for (i = 0; i < jb.length; i++)
      for (j = 0; j < jb[i].length; j++)
           jb[i][j].addActionListener(
             new ActionListener() {
               public void actionPerformed(ActionEvent e) {
              String command = e.getActionCommand();
              String[] indices = command.split(" ");
              int i = Integer.parseInt(indices[0]);
              int j = Integer.parseInt(indices[1]);
              int[] r = {i - 1, i, i + 1, i};
              int[] c = {j, j + 1, j, j - 1};
                for (int k = 0; k < 4; k++) {
                 if (r[k] >= 0 && r[k] < 4 && c[k] >= 0 && c[k] < 4){
                    JButton button = jb[r[k]][c[k]];
                    if (button.getText().equals("")) {
                      button.setText(jb[i][j].getText());
                      jb[i][j].setText("");
                    }
                 }
                }
            }
        });

        newItem.addActionListener(
            new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    init(false);
                }
            }
        );
    }
    public void init(boolean firstTime) {
        ArrayList a = new ArrayList();
        int i, j, k;
        for (i = 1; i <= 15; i++)
            a.add(new Integer(i));
        Collections.shuffle(a);
        a.add(new Integer(0));

        k = 0;
        for (i = 0; i < jb.length; i++)
            for (j = 0; j < jb[i].length; j++) {
                Integer val = (Integer)a.get(k++);
                if (firstTime) {
                    jb[i][j] = new JButton(val.intValue() + "");
                    jb[i][j].setActionCommand(i + " " + j);
                    add(jb[i][j]);
                }
                else
                    jb[i][j].setText(val.intValue() + "");
            }
        jb[3][3].setText("");
            minute = 0;
            second = 0;
    }

    public static void main(String[] args) {
        jf = new JFrame();
        jf.setDefaultCloseOperation(jf.EXIT_ON_CLOSE);

        JMenuBar jmb = new JMenuBar();
        jf.setJMenuBar(jmb);

        JMenu gameMenu = new JMenu("Game");
        jmb.add(gameMenu);
       
        newItem = new JMenuItem("New");
        gameMenu.add(newItem);

        gameMenu.addSeparator();

       
        FifteenPuzzle2 fp = new FifteenPuzzle2();
        jf.setContentPane(fp);

        final DecimalFormat dc = new DecimalFormat("00");

        t = new javax.swing.Timer(
            1000,
            new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    jf.setTitle(dc.format(minute) + ":" + dc.format(second));
                    second++;
                    if (second >= 60) {
                        second %= 60;
                        minute++;
                    }
                }
            }
        );
        jf.pack();
        jf.setVisible(true);
        Dimension d=Toolkit.getDefaultToolkit().getScreenSize();
        int w=(int)d.getWidth();
        int h=(int)d.getHeight();
        jf.setLocation((int)(w/2-jf.getWidth()/2),(int)(h/2-jf.getHeight()/2));
        t.start();
    }
}


You can also download the source code from following links -
DOWNLOAD the JAVA source code from MediaFire
DOWNLOAD the JAVA source file from 4shared

Java program to create a Kaun Banega Crorepati game

This one multi file application. It is done using concept of thread, Java Swing, Java2D, elementary file handling and inheritance. Its completely a fun game which is quite like a quiz. The questions are in a random manner which are initially in several text files. The text are placed according to co-ordinate systems.Images are added to give a different look.
Click to DOWNLOAD the ZIP file from 4shared.com

Wednesday 16 November 2011

Java program to design a Minesweeper game.

This program creates a Minesweeper game as on WindowsXP. It basically uses 2 arrays to save the position of hidden mines. Every time mine position changes using random function. JButton is used and it returns a action value to check which one has been hit. A timer is also added to calculate the total time to solve it.

Click to DOWNLOAD the archive from 4shared.com

C program to perform deletion of nodes in a doubly link list

This program includes deletion of head node, last node and any node from middle. This program is not a menu driven one. The program is a memory efficient one as it releases the memory which contained the data after its deletion using free() function.

Click to DOWNLOAD the C file from 4shared.com

Java program to do simple animation

This program is a simple ball jumping animation. This one is done using concept of co-ordinates, inheritance, java2D and threading. It is displayed on frame with JPanel. After each movement of ball the background is repainted to erase the trail of ball.

Click to DOWNLOAD the JAVA file from 4shared.com

Monday 14 November 2011

C program for insertion in a doubly link list

This program is done by using linked list. The insertion program here os not menu-driven. It inserts at head , last, middle after a particular node and in the middle before a particular node.The forward and backward links are done using structure pointers inside a structure definition.

Click to DOWNLOAD the C file from 4shared.com


Sunday 13 November 2011

C program to convert infix to postfix

This program converts a given infix expression to its equivalent postfix. It is done using stack. It considers operators +,-,*,/,^ and also brackets, it only does not checks whether the infix expression is correct or not. Here it first checks whether operatoe or not. If operator then it is inserted into stack on priority basis. If left bracket it is pushed onto stack and if a right bracket elements are popped from stack and added to postfix till a left bracket encountered. Otherwise if operand it is added to postfix.

Click to DOWNLOAD the C file from 4shared.com

C program of implementation of stack

This program creates a stack and perforns push, pop and display operations on a stack. It is implemented using linked list. Stack is a Last In First Out (LIFO) data structure. To follow this insertion in linked list is done at head node and deletion is also done from head end. Another method can also be followed by insertion at end and deletion from the last node.

Click to DOWNLOAD the C file from 4shared.com

Neutrino travels faster than light

Click hereread the article