1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
IrinaK [193]
2 years ago
13

Edhesive unit 2 lesson 5 coding activity 1 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
Computers and Technology
1 answer:
SVEN [57.7K]2 years ago
4 0

Answer:

public class Polygon {

   private String name;

   private int sides;

   private double sideLength;

   public Polygon(String name, int sides, double sideLength) {

       if (sideLength <= 0) throw new IllegalArgumentException("Length cannot be zero or negative.");

       if (sides <= 0) throw new IllegalArgumentException("Sides cannot be zero or negative.");

       this.name = name;

       this.sides = sides;

       this.sideLength = sideLength;

   }

   public String getName() {

       return name;

   }

   public void setName(String name) {

       this.name = name;

   }

   public double getSideLength() {

       return sideLength;

   }

   public void setSideLength(double sideLength) {

       if (sideLength <= 0) throw new IllegalArgumentException("Length cannot be zero or negative.");

       this.sideLength = sideLength;

   }

   public int getSides() {

       return sides;

   }

   public void setSides(int sides) {

       this.sides = sides;

   }

   (use the at sign here)Override

   public String toString() {

       return "regular " + name + " with side length " + String.format("%.1f", sideLength);

   }

}

public class TestPolygon {

   public static void main(String[] args) {

       Polygon sides11 = new Polygon("hendecagon", 11, 1);

       Polygon sides14 = new Polygon("tetrakaidecagon", 14, 1);

       Polygon sides19 = new Polygon("enneadecagon", 19, 1);

       System. out. println(sides11);

       System. out. println(sides14);

       System. out. println(sides19);

   }

}

Explanation:

This java source code defines a class that creates a regular polygon based on the number of sides given to it.

Below is a screenshot of the program code and output.

You might be interested in
Which of the following information sources was not directly affected by the Telecommunications Act of 1996?
VMariaS [17]
Apparently, the answer is newspaper publishing.

Since telecommunication is defined to use wireless and electrical protocols to transmit data.
6 0
3 years ago
Renee uses data from the Bureau of Labor Statistics to create a graph for a feasibility report. Which of the following should sh
Lena [83]
. A source note for the data.
5 0
2 years ago
Read 2 more answers
What is the diffrence between the the grassland and the savanna biomes
sergey [27]

Answer:

The term "savanna" is often used to refer to open grassland with some tree cover, while "grassland" refers to a grassy ecosystem with little or no tree cover.

Explanation:

5 0
3 years ago
Read 2 more answers
What is a program that, when installed on a computer, records every keystroke and mouse click?
Mrac [35]
"Key logger" This could be software or hardware that does this.
6 0
3 years ago
Which of the following is NOT an example of editing?
Genrish500 [490]

Answer:

ang answer po at proofreading written

content

Explanation:

if I wrong please correction me!

8 0
2 years ago
Other questions:
  • In what scenario should dhcp servers also be active dhcp clients?
    8·1 answer
  • Observe the things at Home in which you are using binary
    7·1 answer
  • Traffic collisions are among the top killers of children in America.
    13·1 answer
  • Is instant messaging a form of synchronous communication
    10·1 answer
  • Where can you place CSS statements in an HTML file?
    7·1 answer
  • What is the difference between coding with html and coding with python
    10·1 answer
  • Which computer peripheral is used when you would like to use a DVD or CD?
    12·2 answers
  • burger hut is trying to decide if it can receive money from the government for providing employees with insurance .
    6·1 answer
  • Create a medical report for Wellness Hospital. Mention the hospital name as the heading and the report name as the subheading. T
    14·1 answer
  • Posts that you delete
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!