Posts

Showing posts from 2011

mouseevent in java

-program based on mouseevent in  java----- - import java.awt.*; import java.awt.event.*; import java.applet.*; /* <applet code="mouse" width=600 height=500> </applet> */ public class mouse extends Applet implements MouseListener,MouseMotionListener { int X=10,Y=50; String msg="MouseEvents"; public void init() { addMouseListener(this); addMouseMotionListener(this); setBackground(Color.yellow); setForeground(Color.red); } public void mouseEntered(MouseEvent m) { setBackground(Color.blue); showStatus("Mouse Entered"); repaint(); } public void mouseExited(MouseEvent m) { setBackground(Color.black); showStatus("Mouse Exited"); repaint(); } public void mousePressed(MouseEvent m) { X=20; Y=40; msg="GTBIT"; setBackground(Color.pink); repaint(); } public void mouseReleased(MouseEvent m) { X=20; Y=40; msg="Engineering"; se

paintbrush applet from jdk

Image
this applet was taken from java development kit to give a java developer an innovative idea.... an applet for paint brush: import java.awt.*; import java.applet.*; import java.util.Vector; public class DrawTest extends Applet {     public void init() { setLayout(new BorderLayout()); DrawPanel dp = new DrawPanel(); add("Center", dp); add("South",new DrawControls(dp));     }     public boolean handleEvent(Event e) { switch (e.id) {  case Event.WINDOW_DESTROY:    System.exit(0);    return true;  default:    return false; }     }     public static void main(String args[]) { Frame f = new Frame("DrawTest"); DrawTest drawTest = new DrawTest(); drawTest.init(); drawTest.start(); f.add("Center", drawTest); f.resize(300, 300); f.show();     } } class DrawPanel extends Panel {     public static final int LINES = 0;     public static final int POINTS = 1;     int   mode = LINES;     Vector

datagrampacket datagramsocket

Image
program based on client-server in java. server program save in one file: import java.net.*; class hi_server { public static DatagramSocket ds; public static byte buffer[]=new byte[1024]; public static void Myserver() throws Exception { int pos=0; while(true) { int c=System.in.read(); switch(c) { case -1: System.out.println("Server quits"); return; case '\r':break; case '\n':ds.send(new DatagramPacket(buffer,pos,InetAddress.getLocalHost(),777));           pos=0; break; default: buffer[pos++]=(byte) c; } } } public static void main(String args[]) throws Exception { System.out.println("Server ready..\n Please type here"); ds=new DatagramSocket(888); Myserver(); } } client program save in as different java file import java.net.*; class hi_client { public static DatagramSocket ds; public static byte buffer[]=new byte[1024]; public static v

notepad in java

Image
//notepad or text-editor in java with source code import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.io.*; import java.util.*; public class notepad extends JFrame implements ActionListener { MenuBar mbar; Menu file,edit,format,font,font1,font2; MenuItem itm1,itm2,itm3,itm4; MenuItem itm5,itm6,itm7,itm8,itm9,itm10; MenuItem fnam1,fnam2,fnam3,fnam4; MenuItem fstyle1,fstyle2,fstyle3,fstyle4; MenuItem fsize1,fsize2,fsize3,fsize4; JPanel mainpanel; TextArea text; Font f; String months[]={ "Jan","Feb","Mar","Apr", "May","Jun","Jul","Aug", "Sep","Oct","Nov","Dec"}; GregorianCalendar gcalendar; String command=" "; String str=" "; String str1=" ",str2=" ",str3=" "; String str4=" "; String str6=" "; String str7=" ",str8=" ",s

url in java

To understand url-uniform resource locator operations in java just run this program ... import java.net.*; import java.io.*; class url { public static void main(String args[]) throws Exception {                URL p1=new URL("http://www.oracle.com:80/docs/path#up"); System.out.println("Protocol:"+p1.getProtocol()); System.out.println("Host :"+p1.getHost()); System.out.println("File Name :"+p1.getFile()); System.out.println("Port :"+p1.getPort()); System.out.println("Reference :"+p1.getRef()); } }

HAPPY DIWALI 2011

Image
Diwali is a traditional festivals that has been celebrated almost in all asian coountries like India,Myanmar,Malaysia,Sri lanka ,Nepal etc.It is festivals of lighting of clay lamps and seeing the beautiful glow of lights that is beauty of lights and an art of yours at  night that says from heart awsome,awsome and out of this world.....So i am not going to miss this day and enjoy it to the fullest with my family and friends..... Here just to say happy diwali to all my colleague and freinds...So i wish millions of lamps illuminate ur life with health,joy,prosperity,love,wealth and happiness forever and ever ..... Happy Diwali 2011 Happy Diwali 2011 itprofessionalsrocks.blogspot.com

GTBIT SQL QUERY

ITPROFESSIONALSROCKS.BLOGSPOT.COM ---2 QUESTION-- ·          Create a database named ‘ Employee’. ·          Use the database ‘Employee’ and create a table ‘Emp’ with attributes ‘ename’,’ecity’,’salary’,’enumber’,’eaddress’,’depttname’. ·          Create another table ‘Company’ with attributes ‘cname’,’ ccity’,’numberof emp’,’empnumber’ in the database ‘Employee’. create database employee use employee create table emp ( ename varchar(20),ecity varchar(20),salary float,enumber int,eaddres varchar(40),deptname varchar(20)); Create table  Company ( cname varchar(20), ccity varchar(20),numberofemp int,empnumber int ) insert into emp values('hemant','delhi',500000,98993142,'karol bagh','techsolution'); insert into emp values('rajiv','delhi',300000,99999234,'moti nagar','finanace'); insert into emp values('raji','delhi',300000,99999234,'moti nagar','manager','finanace'); ins

JAVA PROGRAM 8

JAVA PROGRAM 8: Create 2 threads such that one of thread prints even nos. and another prints odd nos. up to 50. itprofessionalsrocks.blogspot.com class A extends Thread { public void run() {  System.out.println("even number from 1 to 50 are given below"); for (int i=1;i<=50;i++) { if(i%2==0) { System.out.println("\n"+i);   }   }   System.out.println("exit from thread a");   }   }   class B extends Thread   {   public void run()   {    System.out.println("odd number from 1 to 50 are given below ");   for(int i=1;i<=50;i++)   {if(i%2!=0)  {    System.out.println("\n"+i);   }   }   System.out.println("exit form thread b");   }   }     class thread     {     public static void main(String args[])     {     A threadA=new A();     B threadB=new B();     System.out.println("Start thread A");     threadA.start();     System.out.println("Start thread B");     threadB.start();     }     }

java program 7

java program 7: Create a user defined exception named “CheckArguments” to check the arguments passed through command line. If no of arguments are less than 5, throw the “CheckArgument” exception else print addition and avg. of all 5 nos. import java.lang.Exception; import java.util.Scanner; import java.io.*; class CheckArguments extends Exception { CheckArguments(String message) {super(message); } } class arguments { public static void main(String args[]) { int a,count=0,sum=0,avg; System.out.println("enter numbers") ; for(int i=0;i<args.length;i++) { a=Integer.parseInt(args[i]); count=count+1; sum=sum+a; } avg=sum/i; try { if(count<5) { throw new CheckArguments("Arguments are greater than 5"); }  else {     System.out.println(sum);     System.out.println(avg); }  } catch (CheckArguments e) {System.out.println("Caught the exception"); } finally { System.out.println("i am always here"); } } }

java program 6

java program 6: itprofessionalsrocks.blogspot.com  WAP to define an exception called "MarksOutOfBound" exception that is thrown if the marks are out of bound. import java.lang.Exception; import java.util.Scanner; import java.io.*; class MarksOutOfBound extends Exception { MarksOutOfBound(String message) {super(message); } } class marksexcep { public static void main(String args[]) { Scanner obj=new Scanner(System.in); int[] a=new int[6]; System.out.println("enter marks for five subjects") ; for(int i=0;i<5;i++) {a[i]=obj.nextInt(); try {if(a[i]>100) { throw new MarksOutOfBound("marks are out of bound"); } } catch (MarksOutOfBound e) {System.out.println("Caught the exception"); } } } }

java program 5:

java program 5: WAP to catch any 3 built in exceptions in java. class exception { public static void main(String args[]) { try { int a=args.length; System.out.println("a="+a); int b=42/a; try { int c[]={1}; c[42]=99; } catch(ArrayIndexOutOfBoundsException e) {System.out.println("Arrays index oob"+ e); } } catch(ArithmeticException e ) { System.out.println("divide by 0"+e); } catch(ArrayStoreException e) { System.out.println("Wrong data type"); }catch(Exception e) { System.out.println("recaught"+ e); } } }

java program 3:

itprofessionalsrocks.blogspot.com java program 3: a simple program demonstrating the concept of inheritance .. class a { int i,j; void show() { System.out.println("i and j"+i+""+j); } } class b extends a {  int k;  void showk(){  System.out.println("k:"+k);  }  void sum()  {  System.out.println("i+j+k:"+(i+j+k));  }  }   class inherit   {   public static void main(String args[])  { a superob=new  a();   b subob=new b();   superob.i=10;   subob.j=20;   subob.showk();   System.out.println("Contents of superOb") ;   subob.i=7;   subob.j=10;   subob.k=11;   System.out.println("Contents of subob");   subob.showk();   System.out.println("Sum of i,j,k in subob");   subob.sum();   }   }

java program 4

itprofessionalsrocks.blogspot.com java program 4: a simple program demonstrating  use of super . class rectangle { float height; float breadth; rectangle(float h,float b) { height=h; breadth=b; } double area() {return height*breadth; } class rectweight extends rectangle { float weight; rectweight(float h,float b,float w) { super(h,b); weight=w; } } class super1 { public static void main(String args[]) { rectweight obj=new rectweight(10,20,50); double are; are=obj.area(); System.out.println("area is"+are); } }

JAVA PROGRAM 2

itprofessionalsrocks.blogspot.com java program 2: To find out whether the roots of the quadratic equation are imaginary,real and equal and unequal .  import java.util.*; import java.lang.Math; class roots { public static void main(String args[]) { double d,d1,d2; Scanner obj=new Scanner(System.in); System.out.println("enter the valur of a"); int a=obj.nextInt(); System.out.println("enter the valur of b"); int b=obj.nextInt(); System.out.println("enter the valur of c"); int c=obj.nextInt();  d=((b*b)-(4*a*c));  if(d>0)  { System.out.println("roots are real and unequal");  System.out.println("value of d"+ d);  d1=(-b+Math.sqrt(d))/2*a;  d2=(-b-Math.sqrt(d))/2*a ;  System.out.println(d1);  }  else if(d==0) { System.out.println("roots are real and equal");  d1=(-b+Math.sqrt(d))/2*a;  System.out.println("roots are"+d1);  }  else if(d<0)  { System.out.println("roots are imaginary

JAVA PROGRAM 1

itprofessionalsrocks.blogspot.com JAVA PROGRAM 1: TO CALCULATE FIBONACCI SERIES IN JAVA RECURSIVELY. import java.util.*; class fibo { public static int fib(int num) {int f; if(num==1) return 0; if(num==2) return 1; else f=fib(num-1)+fib(num-2); return f; }        public static void main(String args[])        {        Scanner obj=new Scanner(System.in);         int i;        System.out.println("enter number of elements to be generated");        int num=obj.nextInt();        for(i=1;i<=num;i++)        System.out.println(fib(i));        }     } FOR OUTPUT JUST PASTE THIS IN BIN FOLDER AND DO AS BELOW: JAVAC FIBO.JAVA JAVA FIBO THEN BY PRINTSCREEN AND PASTE IT IN PAINT .....

nibble and its reverse

//nibble and decimal number  reverse  a simple illustrations through program. itprofessionalsrocks.blogspot.com #include<iostream.h> #include<conio.h> void main() {   int a,p,d,t,i=1,nib=0,rev=0;   cout<<"enter the decimal number" ;   cin>>a;   p=a;   while(a>0)   {    t=a%4;    nib=nib+t*i;    i=i*10;    a=a/4;   }   cout<<nib;   while(p>0)   { d=p%10;   rev=rev*10+d;   p=p/10;   }      cout<<"number after reversing"<<rev;   getch(); } itprofessionalsrocks.BLOGSPOT.COM

dec 2 hex 2 oct 2 bin

itprofessionalsrocks.blogspot.com //decimal to hexadecimal conversion,octal conversion,binary conversion //dec 2 hex 2 oct 2 bin CONVERSION// #include<iostream.h> #include<conio.h> void main() { clrscr(); int a,d,t,p,k=1,i=1,j=1; int bin=0,bin1=0,bin2=0,bin3=0,rev=0; cout<<"enter the number"; cin>>a; cout<<"enter the number for its conversion to binary"; cin>>t; p=a; while(a>0) { d=a%8; bin=bin+i*d; a=a/8; i=i*10; } while(t>0) { d=t%2; bin1=bin1+j*d; t=t/2; j=j*10; } while(p>0) { d=p%16; bin2=bin2+k*d; p=p/16; k=k*10; } cout<<"binary\n"<<bin1; cout<<"octal\n" <<bin; cout<<"hexadecimal\n"<<bin2; getch(); }

prime in java

to calculate whether the number is prime or not.prime in java javalearing.blogspot.com itprofessionalsrocks.blogspot.com class prime { public static void main(String args[]) { int num=11; int i; for( i=2;i<num;i++) { int n=num%i; if(n==0) { System.out.println("not prime"); break; } } if(i==num){ System.out.println("prime number"); }  }   }

package implementation in java

itprofessionalsrocks.blogspot.com Here we will show u a simple program of packages and its implementation. first create a package naming pack(any name)then create class and its method should be static and public  as shown  below: package pack; public class hemant { public static void show(String s) {     System.out.println(s);     }     } save above as hemant.java now compile your file as: javac hemant.java now make another file in which you wanted to import your package for example demo.java import pack.hemant; //for importing package pack having class name hemant class demo { public static void main(String args[]) { hemant.show("hi bye"); } } save above as demo.java compile your package class first:        javac hemant.java compile your another file create by you: javac demo.java run your demo file:java demo output: hi bye finally you get the clear concept of packages.

JAVA PROGRAM ON OBJECTS AND ITS CLASS

itprofessionalsrocks.blogspot.com HERE WE HAVE BOX AS A CLASS WITH WIDTH,HEIGHT AND DEPTH AS ATTRIBUTES AND VOLUME AS METHOD.PROGRAM IS SELF EXPLAINATORY. class box { double width; double height; double depth; public void volume() { System.out.println("volume is "); System.out.println(width*height*depth); } } class boxdemo { public static void main(String args[]){ box mybox1=new box(); box mybox2=new box(); mybox1.width=100; mybox1.height=20; mybox1.depth=10; mybox2.width=3; mybox2.height=6; mybox2.depth=7; mybox1.volume(); mybox2.volume(); } }

NOTEPAD OPENING USING JAVA

itprofessionalsrocks.blogspot.com QUESTION:NOTEPAD OPENING USING JAVA: Here we use ProcessBuilder class and create its object following is a simple program opening notepad using java. import java.io.*; import java.util.*; class notepad { public static void main(String args[]) { try { ProcessBuilder proc=new ProcessBuilder("notepad.exe","report"); proc.start(); } catch (Exception e) { System.out.println("notepad not open"); } } }

Top5 websites

Image
IT COMPANIES ALWAYS ROCKS ON. itprofessionalsrocks.blogspot.com Top5 websites across the world(According to alexa) 1.Google : Its obvious no doubts google the number websites because of its powerful search engine that can search any letter to any world from small to big.This website is visited by 50.58 percent of all Internet users.Details are as under: ESTIMATED WORTH :$11.08 billion Daily Unique Visitor s: 304,480,000 Daily Pageviews : 1,518,400,000 Daily Ad Earnings : $22.85 million 2.Facebook : Now the second award goes to Facebook the best social networking sites because whenever a person become online his first attempt or wish is to open his Facebook account . Details are as under: Estimated Worth : $11.23 billion Daily Unique Visitors : 263,820,000 Daily Pageviews : 1,538,950,000 Daily Ad Earning s: $22.16 million 3.YOUTUBE : Third rank goes to youtube this is natural because to know anything visully and hand on experience we usully visit it or learni

SOLAR SYSTEM MAKING THROUGH COMPUTER GRAPHICS.

itprofessionalsrocks.blogspot.com /* SOLAR SYSTEM CREATED BY HEMANT GUPTA IT-4th SEMESTER EVENING BATCH */ #include <GRAPHICS.H> #include <stdio.h> #include<math.h> #include<conio.h> #include<dos.h> int stangle = 0, endangle = 360; int xr = 100, yr = 50,xr2=120,yr2=60,xr3=160,yr3=70,xr4=180; int yr4=80,xr5=200,yr5=100,xr6=220,yr6=120,xr7=240,yr7=140,xr8=260,yr8=160; void main() { clrscr(); int gd=DETECT,gm; float xc=300,yc=200,x,y,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6,x7,y7,x8,y8,l,r,a,i,rad; initgraph(&gd,&gm,"f:\\TC\\bin\\BGI"); printf("\nEnter the length\n");  //length scanf("%f",&l); printf("\nEnter radius\n");     //radius of planets scanf("%f",&r); printf("\nEnter angle\n");     //angle =180 for solar system scanf("%f",&a); a=a/2; while(!kbhit()) { for(i=-a;i<=a;i++) {  outtextxy(100,100,"solar system") ; setcolor(14);  circle

JAVA PROGRAMS

FOR ALL YOUR JAVA PROGRAMS U CAN VISIT WWW.JAVALEARING.BLOGSPOT.COM itprofessionalsrocks.blogspot.com

INFOSYS LAUNCHING A SOCIAL NETWORKING

itprofessionalsrocks.blogspot.com 'Infy Bubble', GOING TO LAUNCH AN internal social networking site  Just like Facebook and allows employees to bridge the gap of communication and develop a caring and friendly atmosphere between its employee and    colleagues   said Nandita Gurjar, Vice President and Group Head, Human Resources, Infosys Limited. This site will have features like adding reviews and comments about their bosses and peers and adding photographs and many more just to maintain a good and friendly atmosphere in the company so that all employee feel their office as home like and surrounded by good and friendly people in order to focus on the main objectives and goals in efficient and effective manners. As we know if every employee of the company  are healthy by mind as well health can lead the company to the top within no time and that only the company wants .Every employee of the company are the real roots on which company success depends and in order to success  

CODING DATA STRUCTURE AND C/C++

CODING DATA STRUCTURE AND C/C++ itprofessionalsrocks.blogspot.com

flowchart to find out type of triangle.

Image
itprofessionalsrocks.blogspot.com

er diagram of student registration system

Image
my website?

usecase diagram for railway reservation

Image
itprofessionalsrocks.blogspot.com

flowchart for quadratic equation

Image
itprofessionalsrocks.blogspot.com

ER diagram for payroll system

Image
itprofessionalsrocks.blogspot.com

ER diagram for library management system

Image
itprofessionalsrocks.blogspot.com

flowchart to find greatest among the three.

Image
itprofessionalsrocks.blogspot.com

USE CASE DIAGRAM OF BANKING MANAGEMENT SYSTEM

Image
itprofessionalsrocks.blogspot.com