Tuesday, 30 April 2013

marquee applet by sunil kumar dheendhwal


//================================================
// MarqueeApplet.java
// Auto-scrolling and dragging text on the screen
// Yannis Stavrakas, Jan '98
//================================================

import java.awt.*;
import java.applet.Applet;

public class MarqueeApplet extends Applet {
    int w, h;  //fixed applet width and height
    String message;
    MarqueeCanvas marquee;
    int mouseX;

//standard applet methods
    public void init() {
        //set html-file-dependent values
        w = Integer.parseInt(getParameter("width"));
        h = Integer.parseInt(getParameter("height"));
        message = getParameter("msg");
        setBackground(Color.white);
        marquee = new MarqueeCanvas(w, h);
    }
    public void start() {
        setLayout(new BorderLayout());
        add("Center", marquee);
        marquee.setMsg(message);
        marquee.initPos();
        marquee.move();
    }
    public void stop() {
        marquee.hold();
        remove(marquee);
    }
    public void destroy() {
    }
    String[][] parameterInfo = {
        {"width", "int", "the applet width"},
        {"height", "int", "the applet height"},
        {"msg", "String", "the marquee message"}
    };

//additional behaviour methods
    public boolean handleEvent (Event evt) {
        switch (evt.id) {
        case Event.MOUSE_DOWN:
            mouseX = evt.x;
            return true;
        case Event.MOUSE_UP:  //change scrolling direction
            if (evt.x == mouseX) {
                marquee.hold();
            }
            else if (evt.x < mouseX) {
                marquee.goLeft(true);
                marquee.move();
            }
            else {  //if (evt.x > mouseX)
                marquee.goLeft(false);
                marquee.move();
            }
            return true;
        }
        return super.handleEvent(evt);
    }
}

//======================================================
// Marquee msg with scrolling & dragging capabilities
// REDUCED CLASS VERSION FOR MINIMAL APPLET SIZE
//======================================================
class MarqueeCanvas extends Canvas implements Runnable {
    //marquee message
    boolean isPicture;  //marquee message is picture or text?
    Image picture;
    String text;
    Font font;
    Color color;
    //marquee dimensions
    int w;
    int h;
    //offscreen marquee image
    Image im = null;
    int imWidth = 0;
    int imHeight = 0;
    Insets insets = new Insets(2, 2, 2, 2);
    //position of image relative to canvas viewport
    int viewX = 0;
    int viewY = 0;
    //mouse X coord while draging
    int mouseX;
    //thread used as a timer for scrolling image
    Thread timerThread = null;
    boolean tempStop = false;  //class stops thread
    boolean stopped = true;    //user stops thread
    //scrolling parameters
    boolean toLeft = true;
    int advance = 1;
    int interval = 10;
    //coords of rectangle to be erased
    int dirtyX = 0;
    int dirtyY = 0;
    int dirtyW = 0;
    int dirtyH = 0;
    //component readiness to create image
    boolean ready = false;
    //draw component borders or not
    boolean borders = false;

//constructors
    public MarqueeCanvas(int w, int h) {
        this.w = w;
        this.h = h;
        //default marquee message attributes
        isPicture = false;
        picture = null;
        text = "";
        font = new Font("Helvetica", Font.BOLD, 12);
        color = Color.red;

        resize(w, h);
    }

//marquee message methods
    public void setMsg(String text) {
        if (timerThread!=null) {
            tempStop = true;
            startTimerThread(false);
        }
        dirtyRect(viewX, viewY, imWidth, imHeight);
        isPicture = false;
        this.picture = null;
        this.text = text;
        makeImage(this.text);
        repaint();
        if (tempStop) {
            tempStop = false;
            startTimerThread(true);
        }
    }

//scrolling parameter methods
    public void goLeft(boolean toLeft) {
        if (timerThread!=null) {
            tempStop = true;
            startTimerThread(false);
        }
        this.toLeft = toLeft;
        if (tempStop) {
            tempStop = false;
            startTimerThread(true);
        }
    }

//image positioning methods (relative to canvas)
    public void initPos() {
        initX();
        initY();
    }
    public void initX() {
        if (timerThread!=null) {
            tempStop = true;
            startTimerThread(false);
        }
        dirtyRect(viewX, viewY, imWidth, imHeight);
        viewX = toLeft? w-1: -(imWidth-1);       //to the edge
        repaint();
        if (tempStop) {
            tempStop = false;
            startTimerThread(true);
        }
    }
    public void initY() {
        if (timerThread!=null) {
            tempStop = true;
            startTimerThread(false);
        }
        dirtyRect(viewX, viewY, imWidth, imHeight);
        viewY = (int)Math.round((h - imHeight) / 2);  //center
        repaint();
        if (tempStop) {
            tempStop = false;
            startTimerThread(true);
        }
    }

//scrolling movement methods
    public void move() {
        startTimerThread(true);
        stopped = false;
    }
    public void hold() {
        startTimerThread(false);
        stopped = true;
    }

//standard overriden methods
    public void paint(Graphics g) {
        g.clearRect(dirtyX, dirtyY, dirtyW, dirtyH);
        resetDirtyRect();
        if (im != null) {
            g.drawImage(im, viewX, viewY, this);
        }
        if (borders) {
            g.drawRect(0, 0, w-1, h-1);
        }
    }
    public void update(Graphics g) {
        paint(g);  //this, with dirtyRect, gives smooth movement
    }
    public boolean handleEvent (Event evt) {
        Component theFrame;  //the father of all
        switch (evt.id) {
        case Event.MOUSE_ENTER:
            theFrame = getParent();
            while (theFrame.getParent() != null)
                theFrame = theFrame.getParent();
            ((Frame)theFrame).setCursor(Frame.W_RESIZE_CURSOR);
            return false;  //allow parent to get the message too
        case Event.MOUSE_EXIT:
            theFrame = getParent();
            while (theFrame.getParent() != null)
                theFrame = theFrame.getParent();
            ((Frame)theFrame).setCursor(Frame.DEFAULT_CURSOR);
            return false;
        case Event.MOUSE_DOWN:
            if (timerThread!=null) {
                tempStop = true;
                startTimerThread(false);
            }
            mouseX = evt.x;
            return false;
        case Event.MOUSE_DRAG:
            dirtyRect(viewX, viewY, imWidth, imHeight);
            viewX += evt.x - mouseX;
            mouseX = evt.x;
            if (viewX < -(imWidth-1)) viewX = -(imWidth-1);
            if (viewX > w-1) viewX = w-1;
            repaint();
            return false;
        case Event.MOUSE_UP:
            if (tempStop) {
                tempStop = false;
                startTimerThread(true);
            }
            return false;
        }
        return super.handleEvent(evt);
    }

//thread methods
    public void run() {
        while (timerThread == Thread.currentThread()) {
            if (toLeft) {
                dirtyRect(viewX+imWidth-advance, viewY, advance, imHeight);
                viewX -= advance;
                if (viewX < -(imWidth-1)) viewX = w-1;
            }
            else {
                dirtyRect(viewX, viewY, advance, imHeight);
                viewX += advance;
                if (viewX > w-1) viewX = -(imWidth-1);
            }
            repaint();
            try { Thread.sleep(interval); }
            catch (Exception e) {};
        }
    }
    void startTimerThread(boolean start) {
        if (start) {
            timerThread = new Thread(this);
            timerThread.start();
        }
        else {
            timerThread = null;
        }
    }

//create image with marquee message
    void makeImage(String text) {
        if ( ! ready) return;
        FontMetrics fm = getFontMetrics(font);
        imWidth = fm.stringWidth(text) + insets.left + insets.right;
        imHeight = fm.getHeight() + insets.top + insets.bottom;
        im = createImage(imWidth, imHeight);

        Graphics imGraph = im.getGraphics();
        imGraph.setColor(color);
        imGraph.setFont(font);
        int fontDescent = fm.getDescent();
        imGraph.drawString(text, insets.left, imHeight-fontDescent-insets.bottom);
        if (borders) {
            imGraph.drawRect(0, 0, imWidth-1, imHeight-1);
        }
        imGraph.dispose();
    }

//sets coords for dirty rectangle
    void dirtyRect(int x, int y, int w, int h) {
        //if first call after resetDirtyRect
        if (dirtyW == 0 || dirtyH == 0) {
            dirtyX = x;
            dirtyY = y;
            dirtyW = w;
            dirtyH = h;
            return;
        }
        //else calculate the bounding rect
        int minX = x < dirtyX? x: dirtyX;
        int maxX = x+w > dirtyX+dirtyW? x+w: dirtyX+dirtyW;
        int minY = y < dirtyY? y: dirtyY;
        int maxY = y+h > dirtyY+dirtyH? y+h: dirtyY+dirtyH;
        dirtyX = minX;
        dirtyY = minY;
        dirtyW = maxX - minX;
        dirtyH = maxY - minY;
    }
    void resetDirtyRect() {
        dirtyW = 0;
        dirtyH = 0;
    }

//overriden method, called by system
    public void addNotify() {
        super.addNotify();
        ready = true;  //green light to create image
    }
}

buffring marquee


import java.applet.*;          // involve applet packages
import java.awt.*;

public class Marquee extends Applet {
   private Image buffer;       // buffer and bufferg are
   private Graphics bufferg;   // used for double fuffering
   private int width;          // applet's wodth
   private int height;         // applet's height
   private String text;        // text for scrolling
   private int x;              // aux variable

   public void init() {        // initialization
      text = getParameter("text"); // get text
      setBackground(new Color(230,230,130));  // set bgcolor
      width = getSize().width;     // get applet's width
      height = getSize().height;   // set applet's height
      buffer = createImage(width, height); // create buffers
      bufferg = buffer.getGraphics();  // for double buffering
      x = width;
   }

   public void update(Graphics g) { //overwrites standard update
      paint(g);
   }

   public void paint(Graphics g) {  // all applet output is here
      bufferg.setColor(getBackground()); // set bgcolor 
      bufferg.fillRect(0, 0, width, height); // clean off-screen buffer
      bufferg.setColor(Color.red);       // set text color
      bufferg.drawString(text, x, 10);   // draw text at (x, y)
      g.drawImage(buffer, 0, 0, this);   // swap the buffers

      if (x < -bufferg.getFontMetrics().stringWidth(text))
         x = width;                      // next string position
      else                               // for drawing
         x = x - 1;

      try {Thread.sleep(30);}            // start animation
      catch(InterruptedException e){}

      repaint();                         // update the buffers
   }
}

MARQUEE IN JAVA APPLET NEW VERSION

Marquee applet source code
//================================================
// MarqueeApplet.java
// Auto-scrolling and dragging text on the screen
// Yannis Stavrakas, Jan '98
//================================================

import java.awt.*;
import java.applet.Applet;

public class MarqueeApplet extends Applet {
    int w, h;  //fixed applet width and height
    String message;
    MarqueeCanvas marquee;
    int mouseX;

//standard applet methods
    public void init() {
        //set html-file-dependent values
        w = Integer.parseInt(getParameter("width"));
        h = Integer.parseInt(getParameter("height"));
        message = getParameter("msg");
        setBackground(Color.white);
        marquee = new MarqueeCanvas(w, h);
    }
    public void start() {
        setLayout(new BorderLayout());
        add("Center", marquee);
        marquee.setMsg(message);
        marquee.initPos();
        marquee.move();
    }
    public void stop() {
        marquee.hold();
        remove(marquee);
    }
    public void destroy() {
    }
    String[][] parameterInfo = {
        {"width", "int", "the applet width"},
        {"height", "int", "the applet height"},
        {"msg", "String", "the marquee message"}
    };

//additional behaviour methods
    public boolean handleEvent (Event evt) {
        switch (evt.id) {
        case Event.MOUSE_DOWN:
            mouseX = evt.x;
            return true;
        case Event.MOUSE_UP:  //change scrolling direction
            if (evt.x == mouseX) {
                marquee.hold();
            }
            else if (evt.x < mouseX) {
                marquee.goLeft(true);
                marquee.move();
            }
            else {  //if (evt.x > mouseX)
                marquee.goLeft(false);
                marquee.move();
            }
            return true;
        }
        return super.handleEvent(evt);
    }
}

//======================================================
// Marquee msg with scrolling & dragging capabilities
// REDUCED CLASS VERSION FOR MINIMAL APPLET SIZE
//======================================================
class MarqueeCanvas extends Canvas implements Runnable {
    //marquee message
    boolean isPicture;  //marquee message is picture or text?
    Image picture;
    String text;
    Font font;
    Color color;
    //marquee dimensions
    int w;
    int h;
    //offscreen marquee image
    Image im = null;
    int imWidth = 0;
    int imHeight = 0;
    Insets insets = new Insets(2, 2, 2, 2);
    //position of image relative to canvas viewport
    int viewX = 0;
    int viewY = 0;
    //mouse X coord while draging
    int mouseX;
    //thread used as a timer for scrolling image
    Thread timerThread = null;
    boolean tempStop = false;  //class stops thread
    boolean stopped = true;    //user stops thread
    //scrolling parameters
    boolean toLeft = true;
    int advance = 1;
    int interval = 10;
    //coords of rectangle to be erased
    int dirtyX = 0;
    int dirtyY = 0;
    int dirtyW = 0;
    int dirtyH = 0;
    //component readiness to create image
    boolean ready = false;
    //draw component borders or not
    boolean borders = false;

//constructors
    public MarqueeCanvas(int w, int h) {
        this.w = w;
        this.h = h;
        //default marquee message attributes
        isPicture = false;
        picture = null;
        text = "";
        font = new Font("Helvetica", Font.BOLD, 12);
        color = Color.red;

        resize(w, h);
    }

//marquee message methods
    public void setMsg(String text) {
        if (timerThread!=null) {
            tempStop = true;
            startTimerThread(false);
        }
        dirtyRect(viewX, viewY, imWidth, imHeight);
        isPicture = false;
        this.picture = null;
        this.text = text;
        makeImage(this.text);
        repaint();
        if (tempStop) {
            tempStop = false;
            startTimerThread(true);
        }
    }

//scrolling parameter methods
    public void goLeft(boolean toLeft) {
        if (timerThread!=null) {
            tempStop = true;
            startTimerThread(false);
        }
        this.toLeft = toLeft;
        if (tempStop) {
            tempStop = false;
            startTimerThread(true);
        }
    }

//image positioning methods (relative to canvas)
    public void initPos() {
        initX();
        initY();
    }
    public void initX() {
        if (timerThread!=null) {
            tempStop = true;
            startTimerThread(false);
        }
        dirtyRect(viewX, viewY, imWidth, imHeight);
        viewX = toLeft? w-1: -(imWidth-1);       //to the edge
        repaint();
        if (tempStop) {
            tempStop = false;
            startTimerThread(true);
        }
    }
    public void initY() {
        if (timerThread!=null) {
            tempStop = true;
            startTimerThread(false);
        }
        dirtyRect(viewX, viewY, imWidth, imHeight);
        viewY = (int)Math.round((h - imHeight) / 2);  //center
        repaint();
        if (tempStop) {
            tempStop = false;
            startTimerThread(true);
        }
    }

//scrolling movement methods
    public void move() {
        startTimerThread(true);
        stopped = false;
    }
    public void hold() {
        startTimerThread(false);
        stopped = true;
    }

//standard overriden methods
    public void paint(Graphics g) {
        g.clearRect(dirtyX, dirtyY, dirtyW, dirtyH);
        resetDirtyRect();
        if (im != null) {
            g.drawImage(im, viewX, viewY, this);
        }
        if (borders) {
            g.drawRect(0, 0, w-1, h-1);
        }
    }
    public void update(Graphics g) {
        paint(g);  //this, with dirtyRect, gives smooth movement
    }
    public boolean handleEvent (Event evt) {
        Component theFrame;  //the father of all
        switch (evt.id) {
        case Event.MOUSE_ENTER:
            theFrame = getParent();
            while (theFrame.getParent() != null)
                theFrame = theFrame.getParent();
            ((Frame)theFrame).setCursor(Frame.W_RESIZE_CURSOR);
            return false;  //allow parent to get the message too
        case Event.MOUSE_EXIT:
            theFrame = getParent();
            while (theFrame.getParent() != null)
                theFrame = theFrame.getParent();
            ((Frame)theFrame).setCursor(Frame.DEFAULT_CURSOR);
            return false;
        case Event.MOUSE_DOWN:
            if (timerThread!=null) {
                tempStop = true;
                startTimerThread(false);
            }
            mouseX = evt.x;
            return false;
        case Event.MOUSE_DRAG:
            dirtyRect(viewX, viewY, imWidth, imHeight);
            viewX += evt.x - mouseX;
            mouseX = evt.x;
            if (viewX < -(imWidth-1)) viewX = -(imWidth-1);
            if (viewX > w-1) viewX = w-1;
            repaint();
            return false;
        case Event.MOUSE_UP:
            if (tempStop) {
                tempStop = false;
                startTimerThread(true);
            }
            return false;
        }
        return super.handleEvent(evt);
    }

//thread methods
    public void run() {
        while (timerThread == Thread.currentThread()) {
            if (toLeft) {
                dirtyRect(viewX+imWidth-advance, viewY, advance, imHeight);
                viewX -= advance;
                if (viewX < -(imWidth-1)) viewX = w-1;
            }
            else {
                dirtyRect(viewX, viewY, advance, imHeight);
                viewX += advance;
                if (viewX > w-1) viewX = -(imWidth-1);
            }
            repaint();
            try { Thread.sleep(interval); }
            catch (Exception e) {};
        }
    }
    void startTimerThread(boolean start) {
        if (start) {
            timerThread = new Thread(this);
            timerThread.start();
        }
        else {
            timerThread = null;
        }
    }

//create image with marquee message
    void makeImage(String text) {
        if ( ! ready) return;
        FontMetrics fm = getFontMetrics(font);
        imWidth = fm.stringWidth(text) + insets.left + insets.right;
        imHeight = fm.getHeight() + insets.top + insets.bottom;
        im = createImage(imWidth, imHeight);

        Graphics imGraph = im.getGraphics();
        imGraph.setColor(color);
        imGraph.setFont(font);
        int fontDescent = fm.getDescent();
        imGraph.drawString(text, insets.left, imHeight-fontDescent-insets.bottom);
        if (borders) {
            imGraph.drawRect(0, 0, imWidth-1, imHeight-1);
        }
        imGraph.dispose();
    }

//sets coords for dirty rectangle
    void dirtyRect(int x, int y, int w, int h) {
        //if first call after resetDirtyRect
        if (dirtyW == 0 || dirtyH == 0) {
            dirtyX = x;
            dirtyY = y;
            dirtyW = w;
            dirtyH = h;
            return;
        }
        //else calculate the bounding rect
        int minX = x < dirtyX? x: dirtyX;
        int maxX = x+w > dirtyX+dirtyW? x+w: dirtyX+dirtyW;
        int minY = y < dirtyY? y: dirtyY;
        int maxY = y+h > dirtyY+dirtyH? y+h: dirtyY+dirtyH;
        dirtyX = minX;
        dirtyY = minY;
        dirtyW = maxX - minX;
        dirtyH = maxY - minY;
    }
    void resetDirtyRect() {
        dirtyW = 0;
        dirtyH = 0;
    }

//overriden method, called by system
    public void addNotify() {
        super.addNotify();
        ready = true;  //green light to create image
    }
}

marquee in java applet

/* import the java.applet class (necessary for all applets) */

import java.applet.*;

/* import the java.awt (Abstract Windows Toolkit) classes */

import java.awt.*;

/* declare a class Marquee that can use all variables and functions
   from the Applet class.  The Runnable interface is needed to 
   provide functions that will allow for the execution of the
   applet; the Runnable function used here is run(). */

public class Marquee extends Applet implements Runnable {

/* define a Thread, t.  Think of a Thread as a process; it can be
   started and stopped as necessary within the code. */

  Thread t;

/* define a String, msg, to hold the text we wish to scroll */

  String msg = "Welcome to the Wonderful World of JAVA!";

/* define an integer, msgWidth, to hold the length of the string
   in pixels. */

  int msgWidth;

/* define an integer, pos, to hold the current X position of the 
  text. */

  int pos;

/* define an integer, yLoc, to hold the Y position of the text. */ 

  int yLoc = 15;

/* init is the first function called in a Java applet. */

public void init()
  {

/* resize the applet window to 400x20 */

    resize(400, 20);

/* set the Background color of the applet to white in the form 
   (Red, Green, Blue) with integer values ranging from 0-255. */

    setBackground(new Color(255, 255, 255));

/* use the getFontMetrics function to get the width of the 
   string, in pixels. */
    
    msgWidth = getFontMetrics(getFont()).stringWidth(msg);

/* set the intital position of the text to the right side of 
   the applet window. */
    
    pos = size().width;

/* set t to be a new Thread within 'this,' the Marquee class. */
    
    t = new Thread(this);

/* start the thread.  This calls the run() function. */
    
    t.start();
  }


/* the paint function is called whenever the window needs
   to be updated; the repaint() statement also calls this
   function.  Here, we use it to draw the msg string at
   the coordinates specified by the pos and yLoc variables. */

public void paint(Graphics g)
  {
    g.drawString(msg, pos, yLoc);
  }


/* t.start() calls the run() function.  Here, the while loop
   will iterate continuously; each iteration will repaint the
   applet (drawing the string five pixels to the left of its
   previous location), and pause for 100 milliseconds.  If the
   complete string has scrolled off to the left side of the applet 
   window (pos <= -msgWidth), reposition the string to the 
   right side of the applet window. */


  public void run()
  {
    while(true)
    {
      repaint();
      pos -= 5;
      try
      {
        t.sleep(100);
      }
      catch(Exception e)
      {
      }
      if (pos <= -msgWidth)
      {
        pos = size().width;
      }
    }
  }
}


Monday, 8 April 2013

Bring a Image In Java Applet Programme




import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Image;
import java.net.URL;


public class im1 extends Applet
{

/**
*
*/
private static final long serialVersionUID = 1L;

public void paint(Graphics g)
{
URL u=getDocumentBase();
Image i=getImage(u, "freedocru476121280x1024to5.jpg ");

g.drawImage(i, 10, 10, 200, 300, this);

}
}

MAKE ANY APPLET LAYOUT





import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*
<applet code="layout.java" width=500 height=500>
</applet>
*/
public class layout extends Applet implements ActionListener
{
        Button b1,b2,b3,b4,b5,b6,b7,b8;
        public void init()
        {
                setLayout(new FlowLayout(FlowLayout.CENTER));
                b1=new Button("red");
                b2=new Button("cyan");
                b3=new Button("pink");
                b4=new Button("yellow");
                b5=new Button("magenta");
                b6=new Button("black");
                b7=new Button("blue");
                b8=new Button("orange");

                add(b1);
                add(b2);
                add(b3);
                add(b4);
                add(b5);
                add(b6);
                add(b7);
                add(b8);

                b1.addActionListener(this);
                b2.addActionListener(this);
                b3.addActionListener(this);
                b4.addActionListener(this);
                b5.addActionListener(this);
                b6.addActionListener(this);
                b7.addActionListener(this);
                b8.addActionListener(this);


        }
        public void actionPerformed(ActionEvent ae)
        {
                String s=ae.getActionCommand();
                if(s.equals("red"))
                setBackground(Color.red);
                if(s.equals("cyan"))
                setBackground(Color.cyan);
                if(s.equals("pink"))
                setBackground(Color.pink);
                if(s.equals("yellow"))
                setBackground(Color.yellow);
                if(s.equals("magenta"))
                setBackground(Color.magenta);
                if(s.equals("black"))
                setBackground(Color.black);
                if(s.equals("blue"))
                setBackground(Color.blue);
                if(s.equals("orange"))
                setBackground(Color.orange);

                repaint();


        }
}


Monday, 1 April 2013

How to find some of digits of any given number

How to find some of digits of any given number

import java.util.*;
class A
{
int a,n,b,z,c=0;

void get()
{
Scanner sc=new Scanner(System.in);
System.out.print("Enter any number ");
n=sc.nextInt();
z=n;
}
void put()
{
while(n!=0)
{
a=n%10;
b=n/10;
n=b;

c=c+a;
}
System.out.print("number is "+z+"sum of all digits is "+c);
}


public static void main(String[] args)
{
A a=new A();
a.get();
a.put();

}}

Fectorial of a number in java


Fectorial of a number

import java.util.*;
class A
{
int a,i,f=1;

void get()
{
Scanner sc=new Scanner(System.in);
System.out.print("Enter the Value of a ");
a=sc.nextInt();
}
void put()
{
for(i=1;i<=a;i++)
{
f=f*i;
}
System.out.print("Fectorial Of "+a+" is "+f);
}

public static void main(String[] args)
{
A a=new A();
a.get();
a.put();

}}

How to find some of three numbers in java


find three numbers sum 


import java.util.*;

class A

{

int a,b,c,d;


void get()

{

Scanner sc=new Scanner(System.in);

System.out.print("Enter the Value of a ");

a=sc.nextInt();

System.out.print("Enter the Value of b ");

b=sc.nextInt();

System.out.print("Enter the Value of c ");

c=sc.nextInt();

}

void put()

{

d=a+b+c;

System.out.print("Sum Of a+b+c is = "+d);

}


public static void main(String[] args)

{

A a=new A();

a.get();

a.put();


}}

SIMPLE PROGRAMME OF JAVA






import java.util.*;

class A

{

int i;


void hello()

{

for(i=1;i<=5;i++)

{

System.out.print("======");

}

}


public static void main(String[] args)

{

A a=new A();

a.hello();

System.out.print("\nHello\n");

a.hello();

System.out.print("\nWELCOME TO SESSION OF JAVA\n");

a.hello();

System.out.print("\nHAVE A NICE SESSION\n");

a.hello();

System.out.print("\nSUCCESSFUL\n");

a.hello();

System.out.print("\nSUCCESSFUL  SUCCESSFUL\n");

a.hello();

System.out.print("\nHAVE A NICE YEAR\n");

a.hello();

System.out.print("\nHAVE A NICE DAY\n");

a.hello();

System.out.print("\nLEARN JAVA CAREFULLY\n");

a.hello();

System.out.print("\nBE CAREFULL\n");

a.hello();

System.out.print("\nWELCOME TO HAVEN WORLD\n");

a.hello();

System.out.print("\nHOPE YOU ENJOY\n");

a.hello();

System.out.print("\nTHANK YOU\n");

a.hello();

}}