Question: * this draws one triangle in the middle. //JAVA Next step: Write a function sierpinski() that takes two parameters, numLevels and size. Your function should

* this draws one triangle in the middle. //JAVA Next step: Write* this draws one triangle in the middle. //JAVA

Next step:

Write a function sierpinski() that takes two parameters, numLevels and size. Your function should print numLevels and size, before recursively calling itself three times with the arguments numLevels - 1 and size / 2. The recursion should stop when numLevels is less than 1. Later, you will replace the print statements with a call to triangle().

Modify main() to interpret its first command-line argument as numLevels. Have it call sierpinski(numLevels, 0.5). You may assume that your program will be run with exactly one command-line argument that is a positive integer.

Make sure that your code compiles.

public class Sierpinski ( public static void main(String[] args) triangle (0.5,0.5,Math.sqrt (3)/2); //write a function that draws triangle; penn draw polygon //30 60 tiangle, manipulate formula, equilateral side length coodinates of xy triangle //based on point //to make recursive call (3), xy is over by this much to the left, side length is cute in half, //same to right, down by this much, assuming using top point public static void triangle (double sideLength, double x, double y)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!