subject

The Polish mathematician Wacław Sierpiński described the pattern in 1915, but it has appeared in Italian art since the 13th century. Though the Sierpinski triangle looks complex, it can be generated with a short recursive function. Your main task is to write a recursive function Sierpinski() that plots a Sierpinski triangle of order n to standard drawing. Think recursively: Sierpinski() should draw one filled equilateral triangle (pointed downwards) and then call itself recursively three times (with an appropriate stopping condition). It should draw 1 filled triangle for n = 1; 4 filled triangles for n = 2; and 13 filled triangles for n = 3; and so forth.
API specification:
When writing your program, exercise modular design by organizing it into four functions, as specified in the following API:

public class Sierpinski {

// Height of an equilateral triangle whose sides are of the specified length.
public static double height(double length)

// 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)

// Draws a Sierpinski triangle of order n, such that the largest filled
// triangle has bottom vertex (x, y) and sides of the specified length.
public static void Sierpinski(int n, double x, double y, double length)

// Takes an integer command-line argument n;
// draws the outline of an equilateral triangle (pointed upwards) of length 1;
// whose bottom-left vertex is (0, 0) and bottom-right vertex is (1, 0); and
// draws a Sierpinski triangle of order n that fits snugly inside the outline.
public static void main(String[] args)
}

Restrictions: You may not change either the scale or size of the drawing window.
Observe the following rules:

DO NOT use System. exit().
DO NOT add the project or package statements.
DO NOT change the class name.
DO NOT change the headers of ANY of the given methods.
DO NOT add any new class fields.
ONLY display the result as specified by the example for each problem.
DO NOT print other messages, follow the examples for each problem.
USE StdIn, StdOut, and StdDraw libraries.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 10:30
Choose the best explanation for the following statement communication is symbolic
Answers: 3
question
Computers and Technology, 22.06.2019 15:20
This os integrated the processing power of windows nt with the easy-to-use gui of windows 98. windows 2000 windows 3.11 windows for workgroups windowa millennium edition
Answers: 1
question
Computers and Technology, 23.06.2019 13:30
Stops: using the information learned in this course, explain three things you will not do when driving. a. b. c. explain why you will not do these things when driving. starts: using the information learned in this course, explain three things you will do when driving. a. b. c. explain why you will do these particular things when driving. explain one thing you will stop doing as a passenger. explain one thing you will start doing as a passenger.
Answers: 3
question
Computers and Technology, 23.06.2019 22:30
You draw two cards from a standard deck of 52 cards, but before you draw the second card, you put the first one back and reshuffle the deck. (a) are the outcomes on the two cards independent? why?
Answers: 3
You know the right answer?
The Polish mathematician Wacław Sierpiński described the pattern in 1915, but it has appeared in Ita...
Questions
question
Mathematics, 29.10.2020 22:20
question
Computers and Technology, 29.10.2020 22:20
question
Mathematics, 29.10.2020 22:20
question
Mathematics, 29.10.2020 22:20
question
Computers and Technology, 29.10.2020 22:20
question
Mathematics, 29.10.2020 22:20
question
History, 29.10.2020 22:20
Questions on the website: 13722363