Simple Shutdown Timer For Windows XP

Source code below will show you how to create simple shutdown timer for Windows XP.

************************************************
COMPLETE SOURCE CODE FOR : ShutdownComputer.java
************************************************


import javax.swing.JOptionPane;

public class ShutdownComputer
{
public static void main(String[]args)
{
int wholeTimeBeforeShutdown=0;

int hour=0;
int minute=0;
int second=0;

try
{
String a=JOptionPane.showInputDialog(null,"HOUR","HOUR BEFORE SHUTDOWN",JOptionPane.QUESTION_MESSAGE);
String b=JOptionPane.showInputDialog(null,"MINUTE","MINUTE BEFORE SHUTDOWN",JOptionPane.QUESTION_MESSAGE);
String c=JOptionPane.showInputDialog(null,"SECOND","SECOND BEFORE SHUTDOWN",JOptionPane.QUESTION_MESSAGE);

if((a==null)||(a.equals("")))
{
a="0";
}

if((b==null)||(b.equals("")))
{
b="0";
}

if((c==null)||(c.equals("")))
{
c="0";
}

int e=Integer.parseInt(a);
int f=Integer.parseInt(b);
int g=Integer.parseInt(c);

wholeTimeBeforeShutdown=wholeTimeBeforeShutdown+((e*60)*60);
wholeTimeBeforeShutdown=wholeTimeBeforeShutdown+(f*60);
wholeTimeBeforeShutdown=wholeTimeBeforeShutdown+(g);

wholeTimeBeforeShutdown=wholeTimeBeforeShutdown*1000;

Thread.sleep(wholeTimeBeforeShutdown);

Runtime.getRuntime().exec("shutdown -s -t 00 -f");
}
catch(Exception exception)
{
exception.printStackTrace();
}
}
}


************************************************
JUST COMPILE AND EXECUTE IT
************************************************

Remove element from array

*************************************************
COMPLETE SOURCE CODE FOR : RemoveElementFromAnArray.java
*************************************************


public class RemoveElementFromAnArray
{
public static void main(String[]args)
{
//Now we want to remove last element,"crocodile"
String[]animal={"lion","tiger","elephant","crocodile"};

//Step 1:Create a temp array with sizeArrayAnimal-1
String[]temp=new String[animal.length-1];

//Step 2:Copy element from "lion" to "elephant" into array temp
System.arraycopy(animal,0,temp,0,(animal.length-1));

//Make animal array point to temp array
animal=temp;

//Print all element in animal
int temp2=0;
while(temp2!=animal.length)
{
System.out.println(animal[temp2]);
temp2=temp2+1;
}
}
}


*************************************************
JUST COMPILE AND EXECUTE IT
*************************************************

Add element in array

Note : Source code below will show you how to add new element in a created array. It will add "monkey" word in an array that contains "lion","tiger","elephant","crocodile" word.

******************************************************
COMPLETE SOURCE CODE FOR : AddElementInArray.java
******************************************************


public class AddElementInArray
{
public static void main(String[]args)
{
//Create array with it's component
String[]animal={"lion","tiger","elephant","crocodile"};

//Add an element - "Monkey"
String a="monkey";

//Step 1:Create temp array (size=(arrayThatWeWantToAddElement)+1)
String[]temp=new String[(animal.length)+1];
System.arraycopy(animal,0,temp,0,animal.length);
temp[temp.length-1]=a;

//Make animal array point to temp array
animal=temp;

//Print all element in animal
int temp2=0;
while(temp2!=animal.length)
{
System.out.println(animal[temp2]);
temp2=temp2+1;
}
}
}


******************************************************
JUST COMPILE AND EXECUTE IT
******************************************************

Copy all contents from one array to other array

*****************************************
COMPLETE SOURCE CODE FOR : CopyArray.java
*****************************************


public class CopyArray
{
public static void main(String[]args)
{
//Create array with it's component
String[]animal={"lion","tiger","elephant","crocodile"};

//Create empty array with size same as animal
String[]animal2=new String[animal.length];

//Copy all element in animal into animal2
System.arraycopy(animal,0,animal2,0,animal.length);

//Print all element in animal2
int temp=0;
while(temp!=(animal.length))
{
System.out.println(animal2[temp]);
temp=temp+1;
}
}
}


*****************************************
JUST COMPILE AND EXECUTE IT
*****************************************

RELAXING NATURE VIDEO