Gadgets

Thursday, 18 October 2012

simple java program enter the values using keyboard

SIMPLE JAVA PROGRAM ENTER THE VALUES USING  KEYBOARD

import java.io.*;
import java.lang.*;
public class Keybord {
    public static void main(String a[]) throws IOException
                               {
      BufferedReader br=new BufferedReader( new InputStreamReader(System.in));     
      System.out.println("Enter Name : ");
      String n=br.readLine();    
      System.out.println("Enter 5 Subjects Marks : ");
      int i=Integer.parseInt(br.readLine());
      int j=Integer.parseInt(br.readLine());
      int k=Integer.parseInt(br.readLine());
      int l=Integer.parseInt(br.readLine());
      int m=Integer.parseInt(br.readLine());
      int g=i+j+k+l+m;     
      System.out.println("Enter P/F(P:pass/F:faile): ");
      char r=(char)br.read();     
     System.out.println("Name : "+n);
     System.out.println("Total Marks :"+g);
     System.out.println("Result P/F(P:pass/F:faile): "+r);           
    }   
}
OUTPUT
Enter Name :
narendar
Enter 5 Subjects Marks :
50
60
90
80
95
Enter P/F(P:pass/F:faile):
p
Name : narendar
Total Marks :375
Result P/F(P:pass/F:faile): p

Monday, 15 October 2012

laugh icon using threads

LAUGH SYMBOL


import java.awt.Color;
import java.awt.Frame;
import java.awt.Graphics;
import java.lang.*;

public class Example {
   
 public static void main(String a[])
   {
     Ex i=new Ex(); 
   }
}
class Ex extends Frame implements Runnable//runnable is an inteface we crate threads using thread class and Runnable interface
{
    
    Thread t;//thread is a class
    Ex()
    {
        this.setBackground(Color.red);//background color for frame
      this.setTitle("smile icon");//title
      this.setSize(600,600);//size of the frame(x,y)
      this.setVisible(true);//frame visibility  is true
      t=new Thread(this);//thread is a class
      t.start();//start() method is used for start the thread
     
    }
    public void paint(Graphics g)//pain is a method. it is used for draw the images and text
    {
        g.setColor(Color.yellow);//set color for smile icon oval
        g.fillOval(50,50,50,50);//smile icon oval size(x,y,width,height)
        g.setColor(Color.white);//set color for eyes
         g.fillOval(60,64,10,10);//eye size(x,y,width,height)
        g.fillOval(80,64,10,10);// " "
        g.setColor(Color.black);//set color for smile icon eye
        g.fillOval(63,66,4,4);//eye size(x,y,width,height)
        g.fillOval(83,66,4,4);// " "
       
       g.setColor(Color.white);//set color for smile icon laugh
        g.fillOval(63,76,20,10);//eye size(x+width,y+height,width,height)
        g.setColor(Color.red);
        g.drawOval(63,76,20,10);
            
    }
     public void run()//run() is a method to run thread
        {
      
        }
}


OUTPUT




smile symbol using threads

SMILE SYMBOL  

import java.awt.*;
import java.lang.*;

public class SmileIcon {
   public static void main(String a[])
   {
     MySmile i=new MySmile(); 
   }
}
class MySmile extends Frame implements Runnable//runnable is an inteface we crate threads using thread class and Runnable interface
{
   
    Thread t;//thread is a class
    MySmile()
    {
        this.setBackground(Color.red);//background color for frame
      this.setTitle("smile icon");//title
      this.setSize(600,600);//size of the frame(x,y)
      this.setVisible(true);//frame visibility  is true
      t=new Thread(this);//thread is a class
      t.start();//start() method is used for start the thread
     
    }
    public void paint(Graphics g)//pain is a method. it is used for draw the images and text
    {
        g.setColor(Color.yellow);//set color for smile icon oval
        g.fillOval(50,50,50,50);//smile icon oval size(x,y,width,height)
        g.setColor(Color.white);//set color for eyes
         g.fillOval(60,64,10,10);//eye size(x,y,width,height)
        g.fillOval(80,64,10,10);// " "
        g.setColor(Color.black);//set color for smile icon eye and arc
        g.fillOval(63,66,4,4);//eye size(x,y,width,height)
        g.fillOval(83,66,4,4);// " "
       
         g.setColor(Color.red);
        g.drawArc(60,55,30,30,-65,-65);//arc size(x+width,y+height,width,height,start angle,arc angle)
     
    }
     public void run()//run() is a method to run thread
        {
       
        }
}

OUTPUT