Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

Use java 

See the image for requirements 

Extension 4 - Draw n-gon
For the final pre-defined choice of extension, you must implement a method that draws a regular polygon w
parameterized number of sides and length for these sides. As the shape is regular, each side will have the s
length.
Examples of regular polygons are the equilateral triangle, square, pentagon, hexagon, etc...
This method must have the following header:
public static void drawNgon (Turtle t, int numSides, int side Length) {
The parameters are used as follows:
• Turtle t
o Used to draw the random shape
int numSides
o The number of sides to draw. If this value is 5, then a pentagon should be drawn for example.
int side Length
o The length of each side to draw
The angle that the Turtle should turn after each side can be found using the following formula:
double angle = 360.0 / numSides
Using this formula, the angle that the Turtle would need to turn each time to make a pentagon would be:
360.0/5 = 72.0
expand button
Transcribed Image Text:Extension 4 - Draw n-gon For the final pre-defined choice of extension, you must implement a method that draws a regular polygon w parameterized number of sides and length for these sides. As the shape is regular, each side will have the s length. Examples of regular polygons are the equilateral triangle, square, pentagon, hexagon, etc... This method must have the following header: public static void drawNgon (Turtle t, int numSides, int side Length) { The parameters are used as follows: • Turtle t o Used to draw the random shape int numSides o The number of sides to draw. If this value is 5, then a pentagon should be drawn for example. int side Length o The length of each side to draw The angle that the Turtle should turn after each side can be found using the following formula: double angle = 360.0 / numSides Using this formula, the angle that the Turtle would need to turn each time to make a pentagon would be: 360.0/5 = 72.0
Expert Solution
Check Mark
Still need help?
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

Thanks you so much!

Another questions: this is my code (see image), and I was trying to let the turtle to draw 4 different sizes sqaures, but after I ran my code, the turtle drew out 4 same size squares, where or how should I fix it(or update it)?

thank you.

53
54 }
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
t.down();
public static void drawRandomS (Turtle t, Random rand, int numSquares, int maxSize) { // Extension
int randomSize = rand.nextInt (maxSize - 0 + 1) + 0;
for (int square = 0; square < numSquares; square++) {
for (int k = 0; k < 4; k++) {
t. forward (randomSize);
t.left (90);
}
}
}
t.up();
t. forward (120);
t.down();
t.up();
t. forward (200);
t.down();
/home/Shapes.java 61:28 Spaces: 4 (Auto)
Console Terminal
X Exceeded wall time
expand button
Transcribed Image Text:53 54 } 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 t.down(); public static void drawRandomS (Turtle t, Random rand, int numSquares, int maxSize) { // Extension int randomSize = rand.nextInt (maxSize - 0 + 1) + 0; for (int square = 0; square < numSquares; square++) { for (int k = 0; k < 4; k++) { t. forward (randomSize); t.left (90); } } } t.up(); t. forward (120); t.down(); t.up(); t. forward (200); t.down(); /home/Shapes.java 61:28 Spaces: 4 (Auto) Console Terminal X Exceeded wall time
Solution
Bartleby Expert
by Bartleby Expert
SEE SOLUTION
Follow-up Question

Can you provide a screenshot? It's a little bit hard to read like this

thank you

 

Solution
Bartleby Expert
by Bartleby Expert
SEE SOLUTION
Follow-up Question

Thank you. But can you use the parameters and the formula given in the image?? 

Solution
Bartleby Expert
by Bartleby Expert
SEE SOLUTION
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

Thanks you so much!

Another questions: this is my code (see image), and I was trying to let the turtle to draw 4 different sizes sqaures, but after I ran my code, the turtle drew out 4 same size squares, where or how should I fix it(or update it)?

thank you.

53
54 }
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
t.down();
public static void drawRandomS (Turtle t, Random rand, int numSquares, int maxSize) { // Extension
int randomSize = rand.nextInt (maxSize - 0 + 1) + 0;
for (int square = 0; square < numSquares; square++) {
for (int k = 0; k < 4; k++) {
t. forward (randomSize);
t.left (90);
}
}
}
t.up();
t. forward (120);
t.down();
t.up();
t. forward (200);
t.down();
/home/Shapes.java 61:28 Spaces: 4 (Auto)
Console Terminal
X Exceeded wall time
expand button
Transcribed Image Text:53 54 } 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 t.down(); public static void drawRandomS (Turtle t, Random rand, int numSquares, int maxSize) { // Extension int randomSize = rand.nextInt (maxSize - 0 + 1) + 0; for (int square = 0; square < numSquares; square++) { for (int k = 0; k < 4; k++) { t. forward (randomSize); t.left (90); } } } t.up(); t. forward (120); t.down(); t.up(); t. forward (200); t.down(); /home/Shapes.java 61:28 Spaces: 4 (Auto) Console Terminal X Exceeded wall time
Solution
Bartleby Expert
by Bartleby Expert
SEE SOLUTION
Follow-up Question

Can you provide a screenshot? It's a little bit hard to read like this

thank you

 

Solution
Bartleby Expert
by Bartleby Expert
SEE SOLUTION
Follow-up Question

Thank you. But can you use the parameters and the formula given in the image?? 

Solution
Bartleby Expert
by Bartleby Expert
SEE SOLUTION
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education