public class RandomColor {
    public static void main(String[] args) {

        PennDraw.setCanvasSize(500, 500);
        PennDraw.text(0.5, 0.8, "Your chosen color is...");

        /*
         * Math.random() gives a random double between [0, 1).
         * We want to transform this range so that we get a random
         * int in the range [0, 255]. We can do this by using
         * multiplication and "casting".
         */
        int red = (int) (Math.random() * 255);
        int green = (int) (Math.random() * 255);
        int blue = (int) (Math.random() * 255);
        PennDraw.setPenColor(red, green, blue);
        PennDraw.filledSquare(0.5, 0.5, 0.2); // use the chosen color to draw

        PennDraw.setPenColor(PennDraw.BLACK);
        PennDraw.square(0.5, 0.5, 0.2); // draw a black outline around the color

        PennDraw.text(0.5, 0.2, "(" + red + ", " + green + ", " + blue + ")");
    }
}