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
You wrote a program to allow the user to guess a number. Complete the code to generate a random integer from one to 10.
just olya [345]

Answer:

randint

Explanation:

Just did my quiz and got a 100%

7 0
3 years ago
Read 2 more answers
What is an undirected graph?
ella [17]

Answer: An undirected graph is the graph that has the connection of the objects in the form of bidirectional edges.This graph is formed for by the attachment of the collection of the objects which get displayed in the form of network and thus, also known as the undirected graph.

The graph is formed by the nodes or objects getting connected and form edges or link(which is typically in the form of line).

.

5 0
3 years ago
How fast will a viral meme spread if it is not contained within 24 hours?
sveta [45]
Well a viral meme would spread very fast, it's a VIRAL meme which means it would spread faster than a normal meme. Even if it is contained in the 24 hour time period it would still become rather popular.
6 0
3 years ago
Read 2 more answers
Directions: Asba student of Contact Center Service, you already have an experience using different computer programs. Try to rem
ELEN [110]

Explanation:

can u suggest a title about quarantine

ex: My quarantine life

8 0
3 years ago
Read 2 more answers
Which of the following can be stored in a computer file?
Fed [463]

Answer:

No image uploaded so there can not be an answer provided by the community. Retry uploading the image?

8 0
3 years ago
Other questions:
  • The two variables causing the point of difference between the time codes are the frequency and the count
    6·1 answer
  • How to recover permanently deleted files from drive
    7·1 answer
  • Which is a description of phishing?
    7·1 answer
  • A Unit of information containing the objects position, rotation, and scale values is called:
    13·1 answer
  • What is the best game of 2020 in pc​
    12·2 answers
  • Write a method that takes a RegularPolygon as a parameter, sets its number of sides to a random integer between 10 and 20 inclus
    8·1 answer
  • What does not stand for​
    15·2 answers
  • Examples of email use that could be considered unethical include _____.
    14·2 answers
  • What was the name of first computer?
    14·1 answer
  • 45 points!!
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!