Free Hosting

2 comments - Post a comment

If you wish to have a professional shared hosting quality in a free hosting package, come and host with 000webhost.com and experience the best service you can get absolutely free.

Founded in December 2006, 000webhost.com has a trusted free hosting members base of over 60,000 members and still counting! Offering professional quality hosting, support, uptime and reliability, we have a great community of webmasters, you'd love to be a part of!
I have been using it for sometime now and had found it quiet satisfying..

Register now and get it all free:
*** 1500 MB of disk space
*** 100 GB of data transfer
*** PHP and MySQL support with no restrictions
*** cPanel control panel
*** Website Builder
*** Absolutely no advertising!

Join us now: http://www.000webhost.com/173150.html

 

Slide Show Applet

13 comments - Post a comment

/* Java applet to display sildeshow to images from a given folder in thumbnail form, images can be selected one by one and can be enable/disable slideshow of images. The thumbnail images are placed in slides folder, the download button(rectangle) downloads the images from the web server, hence a webserver is required eg : any webserver even tomcat webserver with download folder with images*/

/* Requirements
1. Name of java file : Sildeshow.java
2. Name of images folder : slides
3. Names of images 1.jpg, 2.jpg and so on upto 8.jpg.
3. Name of download folder in webserver : download
4. Download images given below and paste them in slides folder :
1.jpg2.jpg3.jpg4.jpg5.jpg6.jpg7.jpg8.jpg
5. Download images given below and paste them in download folder in webserver :
1.jpg2.jpg3.jpg4.jpg5.jpg6.jpg7.jpg8.jpg

Java Code for Sildeshow

import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
public class Slideshow extends Applet implements Runnable
{
// Variable Declaration
Thread runner;
boolean left,right,click,auto;
boolean but0,but1;
boolean b0,b1;
boolean waitMessage = true;
String str_desc[] = { // Display Messages
" This is an Abstract piece.Painted on:20/11/86.",
" This picture is an Abstract work.Painted on:10/1/89.",
" This picture is a Canvas oil painting (15/8/92).",
" This is a Pastel painting (2/10/99).",
" This picture is an Abstract piece.Painted on:6/5/03.",
" This is a Brush painting (2/6/05).",
" This a painted collage (30/1/83).",
" This is my Graphical art piece.Painted on:20/12/08."};
int number=1;
static final int MAX=8;
Image Picture[]=new Image[MAX]; // Image variable
Image Buffer;
Graphics gBuffer; // Graphics Variable
Font a = new Font("Helvetica", Font.PLAIN,12);
Font b = new Font("Dialog", Font.PLAIN,10);
Font c = new Font("Helvetica", Font.BOLD,13);
Rectangle r0=new Rectangle(400,70,50,20); // ON / OFF
Rectangle r1=new Rectangle(400,195,120,20); // Click Here
void loadGraphics()
{ //
Track the status of a number of media objects
MediaTracker t=new MediaTracker(this);
for(int i=0;i< MAX;i++)
{
// Load an image in an applet
Picture[i]=getImage(getCodeBase(),"slides/"+(i+1)+".jpg");
t.addImage(Picture[i],0);
try{
t.waitForAll(0);
}
catch(InterruptedException e)
{
}
waitMessage=false;
}
}

public void init()
{
// Creates an image
Buffer=createImage(size().width,size().height);
gBuffer=Buffer.getGraphics();
// Creates a graphics context for this component
}
public void start()
{
if (runner == null)
{
runner = new Thread (this);
runner.start();
}
}
public void stop()
{
if (runner != null)
{
runner.stop();
runner = null;
}
}
public void run()
{
while(true)
{
try
{
runner.sleep(2500);
}
catch (Exception e)
{ }
if(auto)
{
if(number< MAX)
number++;
else
number=1;
}
repaint();
}
}
public void update(Graphics g)
{ paint(g); }
public void drawArrow(int w,int h,int x,int y,boolean left,boolean over,boolean click)
{
if(click&&over) // set color to yellow on click or mouse over
gBuffer.setColor(Color.yellow);
else
if(over) // set color to orange on mouse over
gBuffer.setColor(Color.orange);
else
// set color to red on click
gBuffer.setColor(Color.red);
if(left)
{
int al[] = {x,x+w,x+w};
int bl[] = {y+h/2,y,y+h};
gBuffer.fillPolygon(al, bl, 3);
}
else {
int ar[] = {x,x,x+w};
int br[] = {y,y+h,y+h/2};
gBuffer.fillPolygon(ar, br, 3);
}
}
public void drawPanel()
{
gBuffer.setColor(Color.white);
gBuffer.fillRect(0,0,size().width,size().height);
// Display Text
drawArrow(40,40,330+70,120,true,left,click);
// Display Left Arrow
drawArrow(40,40,380+70,120,false,right,click);
// Display Right Arrow
gBuffer.setColor(Color.lightGray);
gBuffer.setFont(b);
gBuffer.setColor(auto?Color.orange:Color.lightGray);
gBuffer.fill3DRect(400,70,50,20,!but0);
// Rectangle for ON rectangle
gBuffer.setColor(b0?Color.red:Color.black);
// Color For ON rectangle
String s=auto?"OFF":"ON";
gBuffer.drawString(s,410,85);
gBuffer.setColor(Color.lightGray);
// Download
s="Click Here";
gBuffer.fill3DRect(400,190,120,20,!but1);
gBuffer.setFont(a);
gBuffer.setColor(b1?Color.red:Color.black);
gBuffer.drawString(s,430,205);
// Display Image
gBuffer.drawImage(Picture[number-1],20,20,this);
gBuffer.setColor(Color.black);
gBuffer.setFont(c);
gBuffer.drawString("Slideshow:",300,80);
gBuffer.drawString("Scroll:",300,140);
gBuffer.drawString("Download it!",300,200);
gBuffer.drawString("Description:",300,35);
gBuffer.setFont(a);
gBuffer.drawString(str_desc[number-1],300,50);
}
public boolean mouseDown(Event evt,int x,int y)
{
if(r0.inside(x,y))
{
but0=true; auto^=true;
}
if(r1.inside(x,y))
{
but1=true;
auto=false;
}
if(but1)
{
String link ="http://localhost:8080/download/"+number+".jpg";
try {
// corresponds to an applet's environment
AppletContext a = getAppletContext();
URL url = new URL(link);
// url of the image to be downloaded
a.showDocument(url,"_blank");
}
catch (MalformedURLException e){
System.out.println(e.getMessage());
}
}
if(left)
{
auto=false;
if(number>1)
number--;
else number=8;
}
if(right)
{
auto=false;

if(number< MAX)
number++;
else
number=1;
}
click=true;
repaint();
return true;
}
public boolean mouseUp(Event evt,int x,int y)
{
but0=but1=click=false;
repaint();
return true;
}
public boolean mouseMove(Event evt,int x,int y)
{
Rectangle rl=new Rectangle(330+70,120,40,40);
Rectangle rr=new Rectangle(380+70,120,40,40);
if(rl.inside(x,y))
left=true;
else
left=false;
if(rr.inside(x,y))
right=true;
else
right=false;
if(r0.inside(x,y))
b0=true;
else
b0=false;
if(r1.inside(x,y))
b1=true;
else
b1=false;
repaint();
return true;
}
public void paint(Graphics g)
{
if(waitMessage)
{ g.setColor(Color.blue);
g.drawString("Loading images, please wait...",200,100);
loadGraphics();
}
else
{
drawPanel();
g.drawImage (Buffer,0,0, this);
}
}
}
//< code ="Slideshow" height ="500" width="500">
//< /applet>

Ps: This program works fine, errors if any kindly leavea comment...

 

Carlsberg launches Web-TV channel about football and fan life.

1 comments - Post a comment

Recently Carlsberg Brewery launched a football web-TV-channel partofthegame.tv.

They launched 5 channels showing all aspects about football from the classic football matches to life as a fan.

Be sure not to miss the video clips about football funnies and rituals from the Football Magic channel or the bizarre story about fans in the stand and how fan culture sometimes go beyond reason.
As an extra feature you can upload your own favourite football and fan moments.

Its an amazing site with loads of features present in it. So log on to partofthegame.tv and experience the diference.

 

Vectors

2 comments - Post a comment

/* Implementation Of Vectors */
import java.util.Vector;
import java.io.*;
public class MainClass extends Thread{
public static void main(String args[]) throws InterruptedException{
Vector v = new Vector();
int num,choice,ch;
boolean tr = true;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try {
do {
System.out.println("1. Add Elements\n2. Delete Elements\n3. Display\n4. Exit");
choice = Integer.parseInt(br.readLine());
switch(choice) {
case 1:
System.out.println("Enter Element : ");
v.add(Integer.parseInt(br.readLine()));
break;
case 2:
int no;
System.out.println("Enter Element : ");
no = Integer.parseInt(br.readLine());
if(v.contains(no))
v.removeElement(no);
break;
case 3:
System.out.println(v);
break;
case 4:
System.out.println("Exiting Application....");
Thread.sleep(2000);
System.exit(0);
break;
default:
System.out.println("ERROR!!! INVALID OPTION!!!");
Thread.sleep(2000);
}
System.out.println("Do YOu want to continue (1 = yes: )");
ch = Integer.parseInt(br.readLine()); }
while(ch==1);
} catch(Exception e){
System.out.println("Error Message: "+e);
}
}}
/**** OutPut ******
1. Add Elements
2. Delete Elements
3. Display
4. Exit
1
Enter Element :
4
Do YOu want to continue (1 = yes: )
1
1. Add Elements
2. Delete Elements
3. Display
4. Exit
1
Enter Element :
6
Do YOu want to continue (1 = yes: )
1
1. Add Elements
2. Delete Elements
3. Display
4. Exit
1
Enter Element :
7
Do YOu want to continue (1 = yes: )
1
1. Add Elements
2. Delete Elements
3. Display
4. Exit
1
Enter Element :
5
Do YOu want to continue (1 = yes: )
1
1. Add Elements
2. Delete Elements
3. Display
4. Exit
3
[4, 6, 7, 5]
Do YOu want to continue (1 = yes: )
1
1. Add Elements
2. Delete Elements
3. Display
4. Exit
2
Enter Element :
7
Do YOu want to continue (1 = yes: )
1
1. Add Elements
2. Delete Elements
3. Display
4. Exit
3
[4, 6, 5]
Do YOu want to continue (1 = yes: )
1
1. Add Elements
2. Delete Elements
3. Display
4. Exit
4
Exiting Application.... */

 

Threads

2 comments - Post a comment

/* Implementation Of Threads */

import java.io.*;
import java.util.*;

class AA extends Thread
{
int i;
public void run()
{
System.out.println("Thread A");
for(i=0;i<5;i++)
{
System.out.println("Thread A : "+i);
yield();
}
}
}
class B extends Thread
{
int i;
public void run()
{
System.out.println("Thread B");
for(i=0;i<5;i++)
{
System.out.println("Thread B : "+i);
yield();
}
}

}
class C extends Thread
{
int i;
public void run()
{
System.out.println("Thread C");
for(i=0;i<5;i++)
{
System.out.println("Thread C : "+i);
yield();
}
}
}
class ThreadLionel
{
public static void main(String []args)
{
AA a = new AA();
B b = new B();
C c = new C();
a.start();
b.start();
c.start();
}
}
/*
--------------------OUTPUT--------------------
Thread A
Thread A : 0
Thread A : 1
Thread B
Thread B : 0
Thread C
Thread C : 0
Thread A : 2
Thread B : 1
Thread C : 1
Thread A : 3
Thread B : 2
Thread C : 2
Thread A : 4
Thread B : 3
Thread C : 3
Thread B : 4
Thread C : 4
*/

 

Matrix Operations

1 comments - Post a comment

/********** Implementation of Matrix Operation Using Arrays *********/
// Matrix Addtion, Subtraction, Transpose, Multiplication

import matrix;

class Matrix
{
public static void main(String args[])
{
int i,j,k;
int mat1 [][]={ {1,2,3}, {4,5,6}, {7,8,9} };
int mat2 [][]={ {10,11,12}, {13,14,15}, {16,17,18} };

//Matrix A
System.out.println("\nMatrix A:");
for(i=0;i< 3;i++)
{
for(j=0;j< 3;j++)
System.out.print("\t"+mat1[i][j]);
System.out.println("");
}

//Matrix B
System.out.println("\nMatrix B:");
for(i=0;i< 3;i++)
{
for(j=0;j< 3;j++)
System.out.print("\t"+mat2[i][j]);
System.out.println("");
}
System.out.println("\nOperation ON Matrices \n1.Addition \n");
int sum [][] = new int [3][3];
for(i=0;i< 3;i++)
{
for(j=0;j< 3;j++)
{
sum[i][j] = mat1[i][j] + mat2[i][j];
System.out.print("\t" + sum[i][j]);
}

System.out.println("");
}

System.out.println("2.Subtraction\n");
int diff[][] = new int[3][3];
for(i=0;i< 3;i++)
{
for(j=0;j< 3;j++)
{
diff [i][j] = mat1[i][j] - mat2[i][j];
System.out.print("\t"+ diff[i][j]);
}
System.out.println("");
}

System.out.println("3. Transpose Of A\n");
int trans[][] = new int[3][3];
for(i=0;i< 3;i++)
{
for(j=0;j< 3;j++)
{
trans [i][j] = mat1[j][i];
System.out.print("\t"+ trans[i][j]);
}
System.out.println("");
}
System.out.println("4.Multiplication\n");
int prod[][] = new int[3][3];
for(i=0;i< 3;i++)
{
for(j=0;j< 3;j++)
{
prod[i][j] = 0;
{
for(k=0;k< 3;k++)
prod[i][j] = prod[i][j]+mat1[i][k]*mat2[k][j];
}
System.out.print("\t"+ prod[i][j]);
}
System.out.println("");

}
}
}

/************* OUTPUT ***************



Matrix A:
1 2 3
4 5 6
7 8 9

Matrix B:
10 11 12
13 14 15
16 17 18

Operation ON Matrices
1.Addition

11 13 15
17 19 21
23 25 27
2.Subtraction

-9 -9 -9
-9 -9 -9
-9 -9 -9
3. Transpose Of A

1 4 7
2 5 8
3 6 9
4.Multiplication

84 90 96
201 216 231
318 342 366
*/

 

Packages : Calculation of Simple and compound Interest

2 comments - Post a comment

/* java program : implementation of packges...
Import a package in a class and use it. */

/*
First.java
*/

package pack;

public class First
{
static double amt,sim,comp,princ = 1000,rate = 0.09;
static int n=2;

public First()
{
System.out.println("\n...Welcome to First Class\n");
}

public static void DisplayData()
{
System.out.println("Principle Amount\t:"+princ+"\nRate Of Interest\t:"+rate*100+"%");
System.out.println("Term\t\t\t:"+n);
}
public static void SimpleInterest()
{
System.out.println("\nDisplaying Simple Interest...");
try
{
Thread.sleep(1000); // do nothing for 1000 miliseconds (1 second)
}
catch(InterruptedException e)
{
e.printStackTrace();
}
sim = (princ*n*rate);
System.out.println("\tInterest\t: "+sim);
}

public static void CompInterest()
{
System.out.println("\nDisplaying Compound Interest...");
try
{
Thread.sleep(1000); // do nothing for 1000 miliseconds (1 second)
}
catch(InterruptedException e)
{
e.printStackTrace();
}
double ans = princ*(1+rate/n);
comp = Math.pow(ans,(double)n*4.0);
System.out.println("\tInterest\t: "+comp);
}
/* public static void main(String []args)
{
First f= new First();
f.DisplayData();
f.SimpleInterest();
f.CompInterest();
}*/
}

/* The socond file imports the first file and calculates the interst*/
/*Second.java*/

import pack.First;

class Second
{
public static void main(String[] args)
{
System.out.println("Running Class Second..");
First first = new First();
first.DisplayData();
first.SimpleInterest();
first.CompInterest();
}
}

/* Output
* Running Class Second..
*
* ...Welcome to First Class
*
* Principle Amount :1000.0
* Rate Of Interest :9.0%
* Term :2
*
* Displaying Simple Interest...
* Interest : 180.0
* Displaying Compound Interest...
* Interest : 1.4221006128366082E24
*/

 

Length Convertor

3 comments - Post a comment

/* (Length Convertor): Simple Java Program to convert miles, kilometers, meter, feet, centimeter and inches
*/
Enter value for Miles: 45

Kilometer: 72.4185
Meter: 72418.5
Feet: 237593.50429815002
Inches: 2851122.0515778
Centimeter: 7241850.011007612

import java.io.*;

public class ConverterIO
{
public static void main(String[] args) throws IOException
{
BufferedReader dataIn = new BufferedReader(new InputStreamReader(System.in));
String strChoose;
int choose;
String strMiles, strKilometer, strMeter, strFeet, strInches, strCentimeter;
double miles, kilometer, meter,feet, inches, centimeter;
boolean done = false;
while (!done)
{
//Getting input from the user
println("\n\n\n\t\tLENGTH CONVERTER");
println("\n\tWhat you would like to convert?");
println("");
println("\t1) Miles 4) Feet");
println("\t2) Kilometer 5) Inches");
println("\t3) Meter 6) Centimeter");
println("\t\t 7) Exit");
print("\n\tEnter your choice: ");
strChoose = dataIn.readLine();
choose = Integer.parseInt(strChoose);

if ((choose < = 0) || (choose >= 8))
{
println("\tInvalid entry, please try again!");
}

switch (choose)
{
case 1:
print("\n\tEnter value for Miles: ");
strMiles = dataIn.readLine();
miles = Double.parseDouble(strMiles);
println("\n\t\tKilometer: " + (miles*1.6093));
println("\t\tMeter: " + (miles*1609.3));
println("\t\tFeet: " + (miles*5279.85565107));
println("\t\tInches: " + (miles*63358.26781284));
println("\t\tCentimeter: " + (miles*160930.0002446136));
break;

case 2:
print("\n\tEnter value for Kilometer: ");
strKilometer = dataIn.readLine();
kilometer = Double.parseDouble(strKilometer);
println("\n\t\tMiles: " + (kilometer*0.6213882));
println("\t\tMeter: " + (kilometer*1000));
println("\t\tFeet: " + (kilometer*3280.8399));
println("\t\tInches: " + (kilometer*39370.0788));
println("\t\tCentimeter: " + (kilometer*100000)); break;

case 3:
print("\n\tEnter value for Meter: ");
strMeter = dataIn.readLine();
meter = Double.parseDouble(strMeter);
println("\n\t\tMiles: " + (meter*621.3882));
println("\t\tKilometer: " + (meter*1000));
println("\t\tFeet: " + (meter*3.2808399));
println("\t\tInches: " + (meter*39.3700788));
println("\t\tCentimeter: " + (meter*100));
break;

case 4:
print("\n\tEnter value for Feet: ");
strFeet = dataIn.readLine();
feet = Double.parseDouble(strFeet);
println("\n\t\tMiles: " + (feet*0.0001893991176));
println("\t\tKilometer: " + (feet*0.0003048));
println("\t\tMeter: " + (feet*0.3048));
println("\t\tInches: " + (feet*12));
println("\t\tCentimeter: " + (feet*30.48));
break;

case 5:
print("\n\tEnter value for Inches: ");
strInches = dataIn.readLine();
inches = Double.parseDouble(strInches);
println("\n\t\tMiles: " + (inches*0.000015783254));
println("\t\tKilometer: " + (inches*0.000025349));
println("\t\tMeter: " + (inches*0.02534));
println("\t\tFeet: " + (inches*0.08333));
println("\t\tCentimeter: " + (inches*2.51));
break;

case 6:
print("\n\tEnter value for Centimeter: ");
strCentimeter = dataIn.readLine();
centimeter = Double.parseDouble(strCentimeter);
println("\n\t\tMiles: " + (centimeter*0.000006218797));
println("\t\tKilometer: " + (centimeter*0.000004));
println("\t\tMeter: " + (centimeter*0.004));
println("\t\tFeet: " + (centimeter*0.032808386877));
println("\t\tInches: " + (centimeter*0.3937008));
break;

case 7:
done = true;
println("\n\tThank you for using this program!");
println("\n\n");
break;

default: throw new NumberFormatException();

} // end switch
} // end while
} // end main

//short cut for print
private static void print(String s)
{
System.out.print(s);
}

//short cut for println
private static void println(String s)
{
System.out.println(s);
}
}

/* Output
LENGTH CONVERTER

What you would like to convert?

1) Miles 4) Feet
2) Kilometer 5) Inches
3) Meter 6) Centimeter
7) Exit

Enter your choice: 1

Enter value for Miles: 45

Kilometer: 72.4185
Meter: 72418.5
Feet: 237593.50429815002
Inches: 2851122.0515778
Centimeter: 7241850.011007612


LENGTH CONVERTER

What you would like to convert?

1) Miles 4) Feet
2) Kilometer 5) Inches
3) Meter 6) Centimeter
7) Exit

Enter your choice: 5

Enter value for Inches: 48.5

Miles: 7.65487819E-4
Kilometer: 0.0012294265
Meter: 1.22899
Feet: 4.041505
Centimeter: 121.73499999999999


LENGTH CONVERTER

What you would like to convert?

1) Miles 4) Feet
2) Kilometer 5) Inches
3) Meter 6) Centimeter
7) Exit

Enter your choice: 7

Thank you for using this program!
*/

 

Bubble Sort

6 comments - Post a comment

/* Java program on Arrays - Bubble sort on numbers
*/

import java.io.*;
class Bubble
{
public static void main(String args[]) throws IOException
{
int num;
System.out.println("Program to demonstrate bubble sort");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the number of elements to be entered <10");
num=Integer.parseInt(br.readLine());
System.out.println("Enter the numbers to be sorted");
int arr[]=new int[10];

for(int i=0;i< num;i++)
{
arr[i]=Integer.parseInt(br.readLine());
}
System.out.println("The number you have entered:");
for(int i=0;i< num;i++)
{
System.out.println(arr[i]);
}
for(int i=0;i< num;i++)
{
for(int j=i+1;j< num;j++)
{
if(arr[i]>arr[j])
{
int temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
}
}
System.out.println("The sorted numbers are");
for(int i=0;i< num;i++)
{
System.out.println(arr[i]);
}

}
}


/********* Output **********

Program to demonstrate bubble sort
Enter the number of elements to be entered <10
5
Enter the numbers to be sorted
8
65
14
23
2
The number you have entered:
8
65
14
23
2
The sorted numbers are
2
8
14
23
65

*/

 

Read A File

3 comments - Post a comment

/***** Java Program to read a file and display it on the screen */

import java.io.*;
public class LioFile
{
public static void main(String args[])
{
try
{
FileReader fr=new FileReader("LioFile.java");
BufferedReader br=new BufferedReader(fr);
String str=" ";
String s1 =" ";
System.out.println(" s1 is "+s1.equals("ass"));

while((str=br.readLine())!=null)
{
System.out.println(str);
}
}
catch(FileNotFoundException fe)
{
fe.printStackTrace();
}
catch(IOException e)
{
e.printStackTrace();
}
}
}

/**** Output ***
s1 is false
import java.io.*;
public class J7
{
public static void main(String args[])
{
try
{
FileReader fr=new FileReader("J7.java");
BufferedReader br=new BufferedReader(fr);
String str=" ";
String s1 =" ";
System.out.println(" s1 is "+s1.equals("ass"));

while((str=br.readLine())!=null)
{
System.out.println(str);
}
}
catch(FileNotFoundException fe)
{
fe.printStackTrace();
}
catch(IOException e)
{
e.printStackTrace();
}


}
}
*/