Sierpinski.java - Compilation javac Sierpinski.java...

This preview shows page 1 - 2 out of 2 pages.

/************************************************************************* * Compilation: javac Sierpinski.java * Execution: java Sierpinski * * @author: * *************************************************************************/ public class Sierpinski { // Height of an equilateral triangle whose sides are of the specified length. public static double height(double length) { double h=length*Math.sqrt(3)/2.0; return h; // WRITE YOUR CODE HERE } // Draws a filled equilateral triangle whose bottom vertex is (x, y) // of the specified side length. public static void filledTriangle(double x, double y, double length) { StdDraw.filledPolygon(new double[] { x, x - (length / 2.0),x + (length / 2.0) }, new double[] { y, y + height(length), y + height(length) }); // WRITE YOUR CODE HERE } // Draws a Sierpinski triangle of order n, such that the largest filled // triangle has bottom vertex (x, y) and sides of the specified length.

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture