Question

Draw a turtle like that in JAVA. It should not take any user input. we assign the parameters values.4. Create a recursive function spiral_square(size, space) that takes the length of the longest square (size) and the distance

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution :

I have used turtle programming in java. In java, Turtle is a feature used to draw using functions.

YOU NEED TO DOWNLOAD JTURTLE IN YOUR COMPUTER AND ADD IT TO YOUR LIBRARY.

(You can see that i have added it in my library in JavaApplication18 package).

new Turtle() : Creates and returns a new turtle object

fd(amount) : Moves the turtle forward by the specified amount

right(angle) : Turns the turtle clockwise

Screenshot & Output:

JavaApplication 18 - NetBeans IDE 8.2 File Edit View Navigate Source Refactor Run Debug Profile Team 90 <default config> T Q-

Code : -

package javaapplication18;
import java.awt.*;
import ch.aplu.turtle.Turtle;
public class JavaApplication18{
public static Turtle turtle = new Turtle();
public static void spiral_square(int size,int space){
turtle.setColor(Color.RED);
turtle.setPenColor(Color.BLUE);
if(size == 0){
return ;
}
else{
turtle.fd(size);
turtle.right(90);
size = size-space;
spiral_square(size,space);
}
}
public static void main(String[] args) {
spiral_square(100,5);
}
}

----x----x-----x-----

Please give your valuable feedback and also rate my efforts.

Thank You

Add a comment
Know the answer?
Add Answer to:
Draw a turtle like that in JAVA. It should not take any user input. we assign...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In Java, Implement a class MyArray as defined below, to store an array of integers (int)....

    In Java, Implement a class MyArray as defined below, to store an array of integers (int). Many of its methods will be implemented using the principle of recursion. Users can create an object by default, in which case, the array should contain enough space to store 10 integer values. Obviously, the user can specify the size of the array s/he requires. Users may choose the third way of creating an object of type MyArray by making a copy of another...

  • Code in JAVA You are asked to implement “Connect 4” which is a two player game....

    Code in JAVA You are asked to implement “Connect 4” which is a two player game. The game will be demonstrated in class. The game is played on a 6x7 grid, and is similar to tic-tac-toe, except that instead of getting three in a row, you must get four in a row. To take your turn, you choose a column, and slide a checker of your color into the column that you choose. The checker drops into the slot, falling...

  • You are the designer and you have been asked to design a speed reducer (gearbox) that will take p...

    power = 3 kW if need any more information please ask !!! You are the designer and you have been asked to design a speed reducer (gearbox) that will take power from the shaft of an electric motor rotating at 1500 rpm and deliver it to a machine that is to operate at approximately at 200 rpm Assume that you have decided to use spur gears to transmit the power [A power equal to the last one digits of your...

  • **JAVA PLEASE!!** CSE205 Assignment 2 ASCII Terrain Generator 5Opts Topics: Arrays Multidimensional Arrays Metho...

    **JAVA PLEASE!!** CSE205 Assignment 2 ASCII Terrain Generator 5Opts Topics: Arrays Multidimensional Arrays Methods Loops and Conditionals Description The goal of this assignment is for you to produce a simple procedurally generated terrain map out of ASCII character symbols. This will be done through simple probability distributions and arrays Use the following Guideline s: Give identifiers semantic meaning and make them easy to read (examples numStudents, grossPay, etc) Keep identifiers to a reasonably short length. User upper case for constants....

  • code in java please:) Part I Various public transporation can be described as follows: A PublicTransportation...

    code in java please:) Part I Various public transporation can be described as follows: A PublicTransportation class with the following: ticket price (double type) and mumber of stops (int type). A CityBus is a PublicTransportation that in addition has the following: an route number (long type), an begin operation year (int type), a line name (String type), and driver(smame (String type) -A Tram is a CityBus that in addition has the following: maximum speed (int type), which indicates the maximum...

  • Please complete the following programming with clear explanations. Thanks! Homework 1 – Programming with Java: What...

    Please complete the following programming with clear explanations. Thanks! Homework 1 – Programming with Java: What This Assignment Is About? Classes (methods and attributes) • Objects Arrays of Primitive Values Arrays of Objects Recursion for and if Statements Selection Sort    Use the following Guidelines: Give identifiers semantic meaning and make them easy to read (examples numStudents, grossPay, etc.) Use upper case for constants. • Use title case (first letter is upper case) for classes. Use lower case with uppercase...

  • Activity: Writing Classes Page 1 of 10 Terminology attribute / state behavior class method header class...

    Activity: Writing Classes Page 1 of 10 Terminology attribute / state behavior class method header class header instance variable UML class diagram encapsulation client visibility (or access) modifier accessor method mutator method calling method method declaration method invocation return statement parameters constructor Goals By the end of this activity you should be able to do the following: > Create a class with methods that accept parameters and return a value Understand the constructor and the toString method of a class...

  • How can we assess whether a project is a success or a failure? This case presents...

    How can we assess whether a project is a success or a failure? This case presents two phases of a large business transformation project involving the implementation of an ERP system with the aim of creating an integrated company. The case illustrates some of the challenges associated with integration. It also presents the obstacles facing companies that undertake projects involving large information technology projects. Bombardier and Its Environment Joseph-Armand Bombardier was 15 years old when he built his first snowmobile...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT