Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed* 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database 19c DBA By Examples Installation And Administration

Authors: Ravinder Gupta

1st Edition

B09FC7TQJ6, 979-8469226970

More Books

Students also viewed these Databases questions

Question

What are the limitations of forward markets?

Answered: 1 week ago

Question

Is conflict always unhealthy? Why or why not? (Objective 4)

Answered: 1 week ago