MIS 260 Practice - week 8
1. Develop a HTML for below program and then, compile and execute the program.
import java.applet.Applet;
import java.awt.*;
// assume that the drawing area is 150 by 150
public class JustOneCircle extends Applet
{
final int radius = 25;
public void paint ( Graphics gr )
{
setBackground( Color.lightGray );
gr.drawOval( (150/2 - radius), (150/2 - radius), radius*2, radius*2 );
}
}
2. Develop a HTML for below program and then, compile and execute the program.
import java.applet.Applet;
import java.awt.*;
// assume that the drawing area is 150 by 150
public class SquareAndRectangle extends Applet
{
final int areaSide = 150 ;
final int width = 100, height = 50;
public void paint ( Graphics gr )
{
setBackground( Color.green );
// outline the drawing area
gr.drawRect( 0, 0, areaSide-1, areaSide-1 );
// draw interiour rectange.
gr.drawRect( areaSide/2 - width/2 ,
areaSide/2 - height/2, width, height );
}
}
3. Write an applet program and a HTML that displays a set of two circles.
Java Assignment 7
Due: will be announced by instructor
Score: 10 points
- Write an applet program that displays a set of three circles in rectangle. Background color should be yellow.
