देश हमें देता हैं सब कुछ हम भी तो कुछ देना सीखें
सूरज हमें रौशनी देता
हवा नया जीवन देतीं हैं
भूख मिटाने को हम सब की
धरती पर होती खेती है
ओरो का भी हित हो जिसमे
हम ऐसा कुछ करना सीखें
देश हमें देता हैं सब कुछ
हम भी तो कुछ देना सीखें
गर्मियों की तपती दोपहर में
पेड़ सदा देते है छाया
सुमन, सुगंद सदा देती है
हम सबको फूलो की माला
त्यागी तरुणों के जीवन से
हम ऐसा कुछ करना सीखें
जो अनपढ़ है उन्हें पढाये
जो चुप है उनको वाणी दे
जो पिछड़े है उन्हें बढ़ाये
प्यासी धरती को पानी दे
हम मेहनत के दीप जलाकर
नया उजाला करना सीखें
देश हमें देता हैं सब कुछ
हम भी तो कुछ देना सीखें ....
this poem which is very close to my heart... i am very much attuned to this since class 6th..
Monday, January 25, 2010
Wednesday, January 20, 2010
basic program to print the execution time of a program
import java.util.*;
class execution_time
{
public static void main(String args[])
{
long startTime=System.currentTimeMillis();
execution_time obj = new execution_time();
obj.show();
long endTime=System.currentTimeMillis();
long t=endTime-startTime;
System.out.println("the execution time for this program is:"+t);
}
void show()
{
int i;
for(i=100;i<1001;i++)
{
System.out.print(i+" ");
}
System.out.println();
}
}
class execution_time
{
public static void main(String args[])
{
long startTime=System.currentTimeMillis();
execution_time obj = new execution_time();
obj.show();
long endTime=System.currentTimeMillis();
long t=endTime-startTime;
System.out.println("the execution time for this program is:"+t);
}
void show()
{
int i;
for(i=100;i<1001;i++)
{
System.out.print(i+" ");
}
System.out.println();
}
}
Monday, January 18, 2010
Saturday, January 16, 2010
simple zodiac program..
import java.io.*;
import java.io.DataInputStream.*;
class zodiac
{
public static void main(String args[]) throws IOException
{
DataInputStream in = new DataInputStream(System.in);
String name;
int i;
System.out.println("Enter your name and know your zodiac sign");
name = in.readLine();
for(i=0;i<1;i++)
{
char c= name.charAt(i);
int j = (int)c;
if( j == 65 || j==97 || j==66 || j==98 )
{
System.out.println("your zodiac sign is Aquarius");
}
if( j == 67 || j==99 || j==68 || j==100 )
{
System.out.println("your zodiac sign is Aries");
}
if( j == 69 || j==101 || j==70 || j==102 )
{
System.out.println("your zodiac sign is Cancer");
}
if( j == 71 || j==103 || j==72 || j==104 )
{
System.out.println("your zodiac sign is Capricorn");
}
if( j == 73 || j==105 || j==74 || j==106 )
{
System.out.println("your zodiac sign is Gemini");
}
if( j == 75 || j==107 || j==76 || j==108 )
{
System.out.println("your zodiac sign is Leo");
}
if( j == 77 || j==109 || j==78 || j==110 )
{
System.out.println("your zodiac sign is Libra");
}
if( j == 79 || j==111 || j==80 || j==112 )
{
System.out.println("your zodiac sign is Pisces");
}
if( j == 81 || j==113 || j==82 || j==114 )
{
System.out.println("your zodiac sign is Sagitarus");
}
if( j == 83 || j==115 || j==84 || j==116 )
{
System.out.println("your zodiac sign is Scorpio");
}
if( j == 85 || j==117 || j==86 || j==118 )
{
System.out.println("your zodiac sign is Taurus");
}
if( j == 87 || j==119 || j==88 || j==120 || j== 89 || j==121 || j==90 || j==122 )
{
System.out.println("your zodiac sign is Virgo");
}
}
}
}
import java.io.DataInputStream.*;
class zodiac
{
public static void main(String args[]) throws IOException
{
DataInputStream in = new DataInputStream(System.in);
String name;
int i;
System.out.println("Enter your name and know your zodiac sign");
name = in.readLine();
for(i=0;i<1;i++)
{
char c= name.charAt(i);
int j = (int)c;
if( j == 65 || j==97 || j==66 || j==98 )
{
System.out.println("your zodiac sign is Aquarius");
}
if( j == 67 || j==99 || j==68 || j==100 )
{
System.out.println("your zodiac sign is Aries");
}
if( j == 69 || j==101 || j==70 || j==102 )
{
System.out.println("your zodiac sign is Cancer");
}
if( j == 71 || j==103 || j==72 || j==104 )
{
System.out.println("your zodiac sign is Capricorn");
}
if( j == 73 || j==105 || j==74 || j==106 )
{
System.out.println("your zodiac sign is Gemini");
}
if( j == 75 || j==107 || j==76 || j==108 )
{
System.out.println("your zodiac sign is Leo");
}
if( j == 77 || j==109 || j==78 || j==110 )
{
System.out.println("your zodiac sign is Libra");
}
if( j == 79 || j==111 || j==80 || j==112 )
{
System.out.println("your zodiac sign is Pisces");
}
if( j == 81 || j==113 || j==82 || j==114 )
{
System.out.println("your zodiac sign is Sagitarus");
}
if( j == 83 || j==115 || j==84 || j==116 )
{
System.out.println("your zodiac sign is Scorpio");
}
if( j == 85 || j==117 || j==86 || j==118 )
{
System.out.println("your zodiac sign is Taurus");
}
if( j == 87 || j==119 || j==88 || j==120 || j== 89 || j==121 || j==90 || j==122 )
{
System.out.println("your zodiac sign is Virgo");
}
}
}
}
Friday, January 15, 2010
bubble sort
import java.io.*;
class mybubble_input
{
public static void main(String args[]) throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int i,j,temp,n,l;
System.out.println("enter the length of numbers u want to sort");
n=Integer.parseInt(br.readLine());
int a[]=new int[n];
l=a.length;
System.out.println("enter unsorted numbers");
for(i=0;i
{
a[i]=Integer.parseInt(br.readLine());
}
System.out.println("the numbers before sorting");
for(i=0;i
{
System.out.print(a[i]+" ");
}
System.out.println(" ");
for(i=0;i
{
for(j=0;j
{
if(a[j]>a[j+1])
{
temp = a[j+1];
a[j+1]=a[j];
a[j]=temp;
}
}
}
System.out.println("numbers after sorting");
for(i=0;i
{
System.out.print(a[i]+" ");
}
}
}
Monday, January 11, 2010
Overriding
class room
{
int length;
int breadth;
room(int x,int y)
{
length=x;
breadth=y;
}
int area()
{
return (length*breadth);
}
}
class bedroom extends room
{
int height;
bedroom(int x,int y,int h)
{
super(x,y);
height = h;
}
int volume()
{
return (length*breadth*height);
}
}
class assignment1
{
public static void main(String args[])
{
bedroom O=new bedroom(14,12,10);
int Area=O.area();
int Volume=O.volume();
System.out.println("area=" +Area);
System.out.println("volume=" +Volume);
}
}
Sunday, January 10, 2010
Saturday, January 9, 2010
program for digital clock java
//// Created By Rahul
import java.applet.*;
import java.awt.*;
import java.util.*;
import java.text.*;
public class basic4 extends Applet implements Runnable {
int width, height;
Thread t = null;
boolean threadSuspended;
int hours=0, minutes=0, seconds=0;
String timeString = "";
public void init() {
width = getSize().width;
height = getSize().height;
setBackground( Color.black );
}
public void start() {
if ( t == null ) {
t = new Thread( this );
t.setPriority( Thread.MIN_PRIORITY );
threadSuspended = false;
t.start();
}
else {
if ( threadSuspended ) {
threadSuspended = false;
synchronized( this ) {
notify();
}
}
}
}
public void stop() {
threadSuspended = true;
}
public void run() {
try {
while (true) {
// Here's where the thread does some work
Calendar cal = Calendar.getInstance();
hours = cal.get( Calendar.HOUR_OF_DAY );
if ( hours > 12 ) hours -= 12;
minutes = cal.get( Calendar.MINUTE );
seconds = cal.get( Calendar.SECOND );
SimpleDateFormat formatter
= new SimpleDateFormat( "hh:mm:ss", Locale.getDefault() );
Date date = cal.getTime();
timeString = formatter.format( date );
// Now the thread checks to see if it should suspend itself
if ( threadSuspended ) {
synchronized( this ) {
while ( threadSuspended ) {
wait();
}
}
}
repaint();
t.sleep( 1000 ); // interval given in milliseconds
}
}
catch (InterruptedException e) { }
}
void drawHand( double angle, int radius, Graphics g ) {
angle -= 0.5 * Math.PI;
int x = (int)( radius*Math.cos(angle) );
int y = (int)( radius*Math.sin(angle) );
g.drawLine( width/2, height/2, width/2 + x, height/2 + y );
}
void drawWedge( double angle, int radius, Graphics g ) {
angle -= 0.5 * Math.PI;
int x = (int)( radius*Math.cos(angle) );
int y = (int)( radius*Math.sin(angle) );
angle += 2*Math.PI/3;
int x2 = (int)( 5*Math.cos(angle) );
int y2 = (int)( 5*Math.sin(angle) );
angle += 2*Math.PI/3;
int x3 = (int)( 5*Math.cos(angle) );
int y3 = (int)( 5*Math.sin(angle) );
g.drawLine( width/2+x2, height/2+y2, width/2 + x, height/2 + y );
g.drawLine( width/2+x3, height/2+y3, width/2 + x, height/2 + y );
g.drawLine( width/2+x2, height/2+y2, width/2 + x3, height/2 + y3 );
}
public void paint( Graphics g ) {
g.setColor( Color.gray );
drawWedge( 2*Math.PI * hours / 12, width/5, g );
drawWedge( 2*Math.PI * minutes / 60, width/3, g );
drawHand( 2*Math.PI * seconds / 60, width/2, g );
g.setColor( Color.white );
g.drawString( timeString, 10, height-10 );
}
}
Subscribe to:
Posts (Atom)