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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started