Solution for Extra Credit Problem of Assignment 1.

import java.awt.*;
import java.applet.*;
import java.util.*;

// this is a Java applet that draws random rectangles
// Assignment 1, CSci 1211
// Created by Elena Machkasova, 1/16/04
// Modified by ...

public class RandomRectangles extends Applet {

    public void paint(Graphics g) {
	// set the background to white
	g.setColor(Color.white);
	g.fillRect(0, 0, 400, 400);

	// create a random number generator
	Random r = new Random();
	
	// fill in your code here:
	g.setColor(Color.red);

	int x = r.nextInt(200);
	int y = r.nextInt(200);
	int h = r.nextInt(200);
	int w = r.nextInt(200);
	g.fillRect(x, y, h, w);

	g.setColor(Color.yellow);
	x = r.nextInt(200);
	y = r.nextInt(200);
	h = r.nextInt(200);
	w = r.nextInt(200);
	g.fillRect(x, y, h, w);

	g.setColor(Color.green);
	x = r.nextInt(200);
	y = r.nextInt(200);
	h = r.nextInt(200);
	w = r.nextInt(200);
	g.fillRect(x, y, h, w);
    }
}

This is an example from CSci 1211 course.