Practical No 29 Java (22202C0002)

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

 Program Code

29.1) DEVELOP A PROGRAM TO DRAW A POLYGON.


import java.awt.*;
import java.applet.*;
public class polygon extends Applet{public void paint(Graphics g)
{int xpoints[] = {30,200,30,200,30};
int ypoints[] = {30,30,200,200,30};
int num = 5;
g.drawPolygon(xpoints,ypoints,num);
}
}
/* <applet code = "polygon" width=230 height = 210></applet>*/
29.2) DEVELOP AN APPLET FOR DRAWING A HUMAN FACE.
import java.awt.*;
import java.applet.*;
public class humanface extends Applet{public void paint(Graphics g)
{g.drawOval(40,40,120,150);
g.drawOval(57,75,30,20);
g.drawOval(110,75,30,20);
g.fillOval(68,81,10,10);
g.fillOval(121,81,10,10);
g.drawOval(85,100,30,30);
g.fillArc(60,125,80,40,180,180);
g.drawOval(25,92,15,30);
g.drawOval(160,92,15,30);
}
}
/* <applet code = "humanface" width=200 height = 300></applet>*/
Write the output of the program.
import java.awt.*;
import java.applet.*;

/* <applet code="Arcs" width=300 height=300></applet> */

public class Arcs extends Applet {


public void paint(Graphics g) {
g.drawArc(10, 40, 70, 70, 0, 75);
g.fillArc(100, 40, 70, 70, 0, 75);
g.drawArc(10, 100, 70, 80, 0, 175);
g.fillArc(100, 100, 70, 90, 0, 270);
g.drawArc(200, 80, 80, 80, 0, 180);
}

}
Conclusion : We learn to create animated shape in JAVA.

You might also like