211k views
2 votes
Instructions Write code which creates three regular polygons with 11, 14 and 19 sides respectively. All side lengths should be 1.0. The code should then print the three shapes, one on each line, in the order given (i.e. the one with 11 sides first and the one with 19 sides last). Sample run: regular hendecagon with side length 1.0 regular tetrakaidecagon with side length 1.0 regular enneadecagon with side length 1.0 To reference the documentation for the Regular Polygon class, click here . Files NOT SUBMITTED SAVE SUBMIT INSTRUCTIONS RUN CODE GRADING HISTORY U2_L5_Activity_One.java NOV 12, 2020 11:26 AM NOV 12, 2020 11:30 AM NOV 12, 2020 11:29 AM 1 2 /* Lesson 5 Coding Activity Question 1 */ 3 4- import java.util.Scanner; 5 import edhesive. shapes.*; 6 7. public class U2_L5_Activity_One{ 8 public static void main(String[] args) { 9 10 /* Write your code here */ 11 12 } 13} 14 15 16 NOV 12, 2020 11:29 AM NOV 12, 2020 11:29 AM NOV 12, 2020 11:29 AM NOVO 11.0 AM

User Tarekahf
by
7.7k points

1 Answer

7 votes

Final answer:

To create regular polygons with different numbers of sides, we can use the RegularPolygon class from the edhesive.shapes package.

Step-by-step explanation:

To create regular polygons with different numbers of sides, we can use the RegularPolygon class from the edhesive.shapes package. The RegularPolygon class allows us to define the number of sides and the side length for the polygons.

To create the three regular polygons with 11, 14, and 19 sides, and side length of 1.0, we can use the following code:

RegularPolygon poly1 = new RegularPolygon(11, 1.0);
RegularPolygon poly2 = new RegularPolygon(14, 1.0);
RegularPolygon poly3 = new RegularPolygon(19, 1.0);

System.out.println("regular hendecagon with side length 1.0");
System.out.println("regular tetrakaidecagon with side length 1.0");
System.out.println("regular enneadecagon with side length 1.0");

This code creates three RegularPolygon objects with different numbers of sides and side lengths. The println() method is used to print the polygons on separate lines. This code initializes three RegularPolygon instances and prints out their names and the side length. Note that the names of polygons with more than 10 sides are not commonly used, so they are referred to by their Greek-based numerical prefixes followed by '-gon'.

User Juliensaad
by
7.6k points